ci: add Gitea Actions workflows (CI/deploy + weekly npm audit)
Some checks failed
CI · Test & Deploy / Playwright tests (push) Failing after 1m41s
CI · Test & Deploy / Deploy to VPS (push) Has been skipped

- ci.yml: run Playwright tests on every push to main, then deploy to VPS
  if tests pass; includes post-deploy health check
- audit.yml: weekly npm audit (Mondays 07:00 UTC), fails on high/critical
- Requires VPS_SSH_KEY secret (already configured in repo settings)
This commit is contained in:
Jaume Garriga Maestre
2026-05-14 11:01:16 +02:00
parent fa39d50e7e
commit 65525a8e76
2 changed files with 104 additions and 0 deletions

77
.gitea/workflows/ci.yml Normal file
View File

@@ -0,0 +1,77 @@
name: CI · Test & Deploy
on:
push:
branches: [main]
jobs:
# ─────────────────────────────────────────────
# JOB 1: Playwright tests
# ─────────────────────────────────────────────
test:
name: Playwright tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci --omit=dev
- name: Install Playwright browsers
run: npx playwright install chromium --with-deps
- name: Start app (static HTTP server)
run: |
npm install --save-dev http-server
npx http-server . -p 9090 &
sleep 2
- name: Run Playwright tests
run: npx playwright test --reporter=list
env:
APP_URL: http://localhost:9090
# ─────────────────────────────────────────────
# JOB 2: Deploy to VPS (only if tests pass)
# ─────────────────────────────────────────────
deploy:
name: Deploy to VPS
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.VPS_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H 80.225.185.50 >> ~/.ssh/known_hosts
- name: Upload static files
run: |
scp -i ~/.ssh/id_ed25519 index.html comarca-paths.js \
ubuntu@80.225.185.50:/srv/docker/data/comarques/public/
- name: Upload server files & rebuild
run: |
ssh -i ~/.ssh/id_ed25519 ubuntu@80.225.185.50 "mkdir -p /srv/docker/builds/comarques"
scp -i ~/.ssh/id_ed25519 server.js package.json Dockerfile \
ubuntu@80.225.185.50:/srv/docker/builds/comarques/
ssh -i ~/.ssh/id_ed25519 ubuntu@80.225.185.50 \
"cd /srv/docker/builds/comarques && docker build -t comarques-de-catalunya:latest . \
&& cd /srv/docker/compose && docker compose up -d comarques"
- name: Health check
run: |
sleep 5
curl -fs https://comarques.jaumegar.work/api/health \
|| (echo "❌ Health check failed after deploy" && exit 1)