Files
originsdigital/.gitea/workflows/deploy.yml
Tetardtek fcd9867670
All checks were successful
CI/CD — Build & Deploy / Build & Deploy (push) Successful in 23s
ci: fix pipeline — vps-runner host mode, remove setup-node, add smoke test
2026-03-14 09:16:57 +01:00

61 lines
2.4 KiB
YAML

name: CI/CD — Build & Deploy
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build-and-deploy:
name: Build & Deploy
runs-on: vps-runner
steps:
- uses: actions/checkout@v4
# ── Backend ──────────────────────────────────────────────────────────────
- name: Install & build backend
working-directory: backend
run: |
npm ci
npm run build
- name: Deploy backend
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
mkdir -p /var/www/originsdigital/backend
rsync -a --delete backend/dist/ /var/www/originsdigital/backend/dist/
rsync -a backend/package.json backend/package-lock.json /var/www/originsdigital/backend/
cd /var/www/originsdigital/backend && npm ci --omit=dev
- name: Restart pm2
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
pm2 restart originsdigital-backend || pm2 start /var/www/originsdigital/backend/dist/index.js --name originsdigital-backend
pm2 save
# ── Frontend ─────────────────────────────────────────────────────────────
- name: Install & build frontend
working-directory: frontend
env:
VITE_API_URL: ${{ secrets.VITE_API_URL }}
VITE_SUPEROAUTH_URL: ${{ secrets.VITE_SUPEROAUTH_URL }}
run: |
npm ci
npm run build
- name: Deploy frontend
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
mkdir -p /var/www/originsdigital/frontend/dist
rsync -a --delete frontend/dist/ /var/www/originsdigital/frontend/dist/
# ── Smoke test ───────────────────────────────────────────────────────────
- name: Smoke test API
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
sleep 3
curl -sf http://localhost:4001/api/health | grep -q '"ok"'
echo "✅ API health OK"