fix: pipeline CI/CD — vps-runner direct deploy (pm2 + rsync)
Some checks failed
CI/CD — Build & Deploy / Build & Deploy (push) Has been cancelled
Some checks failed
CI/CD — Build & Deploy / Build & Deploy (push) Has been cancelled
Remplace le flow Docker (docker compose up) par le vrai modèle : - Job unique sur vps-runner (runner local sur le VPS) - Build backend → rsync vers /var/www/originsdigital/backend/ → pm2 restart - Build frontend avec VITE_API_URL/VITE_SUPEROAUTH_URL → rsync vers /var/www/originsdigital/frontend/dist/ - Suppression appleboy/ssh-action (inutile, le runner est sur le VPS)
This commit is contained in:
@@ -7,9 +7,9 @@ on:
|
|||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-and-deploy:
|
||||||
name: Build
|
name: Build & Deploy
|
||||||
runs-on: ubuntu-latest
|
runs-on: vps-runner
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -21,31 +21,36 @@ jobs:
|
|||||||
backend/package-lock.json
|
backend/package-lock.json
|
||||||
frontend/package-lock.json
|
frontend/package-lock.json
|
||||||
|
|
||||||
|
# ── Backend ──────────────────────────────────────────────────────────────
|
||||||
- name: Install & build backend
|
- name: Install & build backend
|
||||||
working-directory: backend
|
working-directory: backend
|
||||||
run: |
|
run: |
|
||||||
npm ci
|
npm ci
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
|
- name: Deploy backend
|
||||||
|
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
|
||||||
|
|
||||||
|
# ── Frontend ─────────────────────────────────────────────────────────────
|
||||||
- name: Install & build frontend
|
- name: Install & build frontend
|
||||||
working-directory: frontend
|
working-directory: frontend
|
||||||
|
env:
|
||||||
|
VITE_API_URL: ${{ secrets.VITE_API_URL }}
|
||||||
|
VITE_SUPEROAUTH_URL: ${{ secrets.VITE_SUPEROAUTH_URL }}
|
||||||
run: |
|
run: |
|
||||||
npm ci
|
npm ci
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
deploy:
|
- name: Deploy frontend
|
||||||
name: Deploy to VPS
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
runs-on: ubuntu-latest
|
run: |
|
||||||
needs: build
|
mkdir -p /var/www/originsdigital/frontend/dist
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
rsync -a --delete frontend/dist/ /var/www/originsdigital/frontend/dist/
|
||||||
steps:
|
|
||||||
- name: Deploy via SSH
|
|
||||||
uses: appleboy/ssh-action@v1
|
|
||||||
with:
|
|
||||||
host: ${{ secrets.SSH_HOST }}
|
|
||||||
username: ${{ secrets.SSH_USER }}
|
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
||||||
script: |
|
|
||||||
cd /home/tetardtek/github/originsdigital
|
|
||||||
git pull origin main
|
|
||||||
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build
|
|
||||||
|
|||||||
Reference in New Issue
Block a user