From bec7ef337eb12a602d0752be37e9d279872501be Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Mon, 2 Mar 2026 12:40:39 -0500 Subject: [PATCH] [ci] Add gitea workflow --- .gitea/workflows/build-deploy.yml | 109 ++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .gitea/workflows/build-deploy.yml diff --git a/.gitea/workflows/build-deploy.yml b/.gitea/workflows/build-deploy.yml new file mode 100644 index 0000000..570b8ae --- /dev/null +++ b/.gitea/workflows/build-deploy.yml @@ -0,0 +1,109 @@ +name: build & deploy + +on: + push: + branches: ["**"] + tags: ["*"] + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + env: + VROBBLER_DATABASE_URL: sqlite:///test.db + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + # Cache pip + Poetry caches (rough equivalent to your mounted pip_cache) + - name: Cache pip/poetry + uses: actions/cache@v4 + with: + path: | + ~/.cache/pip + ~/.cache/pypoetry + key: ${{ runner.os }}-py311-${{ hashFiles('**/poetry.lock') }} + restore-keys: | + ${{ runner.os }}-py311- + + - name: Install Poetry + run: | + python -m pip install --upgrade pip + pip install poetry + + - name: Install deps + run: | + cp vrobbler.conf.test vrobbler.conf + poetry install --with test + + - name: Pytest with coverage + run: | + poetry run pytest -n 5 --cov-report term:skip-covered --cov=vrobbler tests + + # Notifications (success/failure) for the test job + - name: Notify success (ntfy) + if: success() + run: | + curl -fsS \ + -H "Title: vrobbler CI success" \ + -H "Priority: low" \ + -H "Tags: success,vrobbler" \ + -d "✅ Build succeeded: ${{ gitea.repository }} @ ${{ gitea.sha }}" \ + https://ntfy.unbl.ink/drone + + - name: Notify failure (ntfy) + if: failure() + run: | + curl -fsS \ + -H "Title: vrobbler CI failure" \ + -H "Priority: high" \ + -H "Tags: failure,vrobbler" \ + -d "❌ Build failed: ${{ gitea.repository }} @ ${{ gitea.sha }}" \ + https://ntfy.unbl.ink/drone + + deploy: + # Only deploy on tags (equivalent to Drone when: ref: refs/tags/*) + if: startsWith(gitea.ref, 'refs/tags/') + needs: [test] + runs-on: ubuntu-latest + + steps: + - name: Deploy via SSH + uses: appleboy/ssh-action@v1.0.3 + with: + host: vrobbler.service + username: root + key: ${{ secrets.JAIL_KEY }} + command_timeout: 2m + script: | + pip uninstall -y vrobbler + pip install git+https://code.lab.unbl.ink/secstate/vrobbler.git@main + vrobbler migrate + vrobbler collectstatic --noinput + immortalctl restart celery && immortalctl restart vrobbler + + - name: Notify deploy success (ntfy) + if: success() + run: | + curl -fsS \ + -H "Title: vrobbler deploy success" \ + -H "Priority: low" \ + -H "Tags: success,vrobbler,deploy" \ + -d "🚀 Deploy succeeded: ${{ gitea.ref_name }} (${{ gitea.sha }})" \ + https://ntfy.unbl.ink/drone + + - name: Notify deploy failure (ntfy) + if: failure() + run: | + curl -fsS \ + -H "Title: vrobbler deploy failure" \ + -H "Priority: high" \ + -H "Tags: failure,vrobbler,deploy" \ + -d "💥 Deploy failed: ${{ gitea.ref_name }} (${{ gitea.sha }})" \ + https://ntfy.unbl.ink/drone