diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..b5a3514 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,88 @@ +name: Deploy mindnet to llm-node + +on: + push: + branches: [ "main" ] + +concurrency: + group: deploy-mindnet + cancel-in-progress: false + +jobs: + deploy: + runs-on: linux_host + env: + # >>> Alle zu deployenden Top-Level-Verzeichnisse/Dateien hier pflegen <<< + # (Neue Ordner einfach anhängen; werden 1:1 nach $TARGET_BASE gespiegelt.) + DEPLOY_DIRS: "app scripts docker requirements.txt README.md" + TARGET_BASE: "/home/llmadmin/mindnet" + steps: + - name: Checkout + uses: https://github.com/actions/checkout@v4 + + - name: Sanity — Runner & Commit + run: | + echo "Runner: $RUNNER_NAME Labels: $RUNNER_LABELS" + echo "Commit: ${GITHUB_SHA:-$GITEA_SHA} Ref: ${GITHUB_REF:-$GITEA_REF}" + uname -a + + - name: Ensure target base exists + run: | + install -d "$TARGET_BASE" + + - name: Deploy whitelisted directories + run: | + set -euo pipefail + IFS=' ' read -r -a DIRS <<< "$DEPLOY_DIRS" + + for d in "${DIRS[@]}"; do + if [ -e "$d" ]; then + if [ -d "$d" ]; then + if [ -n "$(find "$d" -mindepth 1 -print -quit)" ]; then + echo ">> Syncing DIR $d -> $TARGET_BASE/$d" + install -d "$TARGET_BASE/$d" + rsync -a --delete \ + --exclude='.git' \ + --exclude='.env' --exclude='.env.*' --exclude='**/.env' --exclude='**/.env.*' \ + "$d"/ "$TARGET_BASE/$d"/ + else + echo ">> Skipping $d (leer)" + fi + else + echo ">> Copying FILE $d -> $TARGET_BASE/$d" + rsync -a "$d" "$TARGET_BASE/$d" + fi + else + echo ">> Skipping $d (nicht vorhanden im Repo)" + fi + done + + - name: Python venv prepare (idempotent) + run: | + set -euo pipefail + cd "$TARGET_BASE" + if [ ! -d ".venv" ]; then + python3 -m venv .venv + fi + source .venv/bin/activate + pip install --upgrade pip + if [ -f "requirements.txt" ]; then + pip install -r requirements.txt + fi + + - name: Optional — systemctl --user restart mindnet-api (ignore if missing) + continue-on-error: true + run: | + if systemctl --user list-unit-files | grep -q '^mindnet-api.service'; then + systemctl --user restart mindnet-api.service + systemctl --user --no-pager status mindnet-api.service --full -l || true + else + echo "mindnet-api.service nicht gefunden — Schritt wird übersprungen." + fi + + - name: Post-check — list targets + run: | + for d in $DEPLOY_DIRS; do + echo "== $TARGET_BASE/$d ==" + ls -la "$TARGET_BASE/$d" 2>/dev/null | tail -n +1 || true + done