Test CI
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
name: Build Nuxt App
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -6,7 +6,7 @@ on:
|
|||||||
- master
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-web:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
@@ -43,12 +43,62 @@ jobs:
|
|||||||
cd dist_package
|
cd dist_package
|
||||||
zip -r ../quibot-web.zip .
|
zip -r ../quibot-web.zip .
|
||||||
|
|
||||||
# Create or update release and upload asset
|
- name: Upload Web artifact
|
||||||
- name: Upload Release
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: quibot-web
|
||||||
|
path: quibot-web/quibot-web.zip
|
||||||
|
|
||||||
|
build-backend:
|
||||||
|
runs-on: docker
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: backend
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
apt update
|
||||||
|
apt install -y zip
|
||||||
|
|
||||||
|
- name: Create zip
|
||||||
|
run: |
|
||||||
|
zip -r backend.zip .
|
||||||
|
|
||||||
|
- name: Upload Backend artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: backend
|
||||||
|
path: backend/backend.zip
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: docker
|
||||||
|
needs: [build-web, build-backend]
|
||||||
|
steps:
|
||||||
|
- name: Download Web Artifact
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: quibot-web
|
||||||
|
path: dist
|
||||||
|
|
||||||
|
- name: Download Backend Artifact
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: backend
|
||||||
|
path: dist
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: latest
|
tag_name: latest
|
||||||
name: Latest Build
|
name: Latest Build
|
||||||
files: quibot-web/quibot-web.zip
|
files: |
|
||||||
|
dist/quibot-web.zip
|
||||||
|
dist/backend.zip
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITEATOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITEATOKEN }}
|
||||||
2
backend/.gitignore
vendored
Normal file
2
backend/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
__pycache__/
|
||||||
|
venv/
|
||||||
26
backend/main.py
Normal file
26
backend/main.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from fastapi import FastAPI, HTTPException
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
|
||||||
|
# Whitelist allowed actions (VERY important)
|
||||||
|
COMMANDS = {
|
||||||
|
"restart_nginx": ["sudo", "systemctl", "restart", "nginx"],
|
||||||
|
"uptime": ["uptime"],
|
||||||
|
"update": ["sudo", "apt", "update"]
|
||||||
|
}
|
||||||
|
|
||||||
|
@app.post("/run")
|
||||||
|
def run_task(task: str, token: str):
|
||||||
|
# simple auth check (replace with real auth later)
|
||||||
|
if token != "MY_SECRET_TOKEN":
|
||||||
|
raise HTTPException(status_code=403, detail="Unauthorized")
|
||||||
|
|
||||||
|
if task not in COMMANDS:
|
||||||
|
raise HTTPException(status_code=400, detail="Invalid task")
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = subprocess.check_output(COMMANDS[task], text=True)
|
||||||
|
return {"output": result}
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
return {"error": e.output}
|
||||||
Reference in New Issue
Block a user