Files
comarques-de-catalunya/.gitea/workflows/ci.yml
Jaume Garriga Maestre 2f90d41be3
Some checks failed
CI · Test & Deploy / Playwright tests (push) Failing after 3m55s
CI · Test & Deploy / Deploy to VPS (push) Has been skipped
ci: fix runner image (node:20), add Playwright smoke tests
- Change runner to node:20 (has bash) instead of node:20-alpine
- Add tests/smoke.spec.js: 7 tests covering title, welcome screen,
  COMARCA_PATHS count (43), Lluçanès/Moianès presence, and
  filter counts (coastal=12, interior=21, mountain=10)
- Add playwright.config.js
- Fix CI workflow: use 'serve' for static server, proper SSH key setup
2026-05-14 11:11:39 +02:00

79 lines
2.6 KiB
YAML

name: CI · Test & Deploy
on:
push:
branches: [main]
jobs:
# ─────────────────────────────────────────────
# JOB 1: Playwright smoke 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'
- name: Install dependencies
run: npm ci
- name: Install Playwright + Chromium system deps
run: npx playwright install chromium --with-deps
- name: Start static HTTP server
run: |
npx --yes serve . -l 9090 &
sleep 3
- name: Run smoke 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
printf '%s\n' "$VPS_SSH_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H 80.225.185.50 >> ~/.ssh/known_hosts
env:
VPS_SSH_KEY: ${{ secrets.VPS_SSH_KEY }}
- 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: |
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" && exit 1)