Files
TetaRdPG/.gitea/workflows/deploy.yml
Tetardtek bab73ae341
All checks were successful
CI/CD — Build & Deploy / Build & Deploy (push) Successful in 39s
fix: CI pm2 start-or-reload — crée le process s'il n'existe pas
2026-04-28 18:41:27 +02:00

62 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
run: |
npm ci
npm run build
- name: Deploy backend
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
mkdir -p /var/www/tetardpg/backend
rsync -a --delete dist/ /var/www/tetardpg/backend/dist/
rsync -a package.json package-lock.json /var/www/tetardpg/backend/
cd /var/www/tetardpg/backend && npm ci --omit=dev
- name: Restart pm2
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
pm2 describe tetardpg-backend >/dev/null 2>&1 \
&& pm2 reload tetardpg-backend --update-env \
|| (cd /var/www/tetardpg/backend && pm2 start dist/main.js --name tetardpg-backend && pm2 save)
# ── Frontend ─────────────────────────────────────────────────────────────
- name: Install & build frontend
working-directory: frontend
env:
VITE_API_URL: https://tetardpg.tetardtek.com/api
VITE_OAUTH_URL: https://superoauth.tetardtek.com
VITE_OAUTH_CLIENT_ID: tetardpg
run: |
npm ci
npm run build
- name: Deploy frontend
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
mkdir -p /var/www/tetardpg/frontend/dist
rsync -a --delete frontend/dist/ /var/www/tetardpg/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:4000/api/health | grep -q '"ok"'
echo "✅ API health OK"