diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 6dd1130..2458a2a 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Frontend Deployment Pipeline +name: Frontend Deployment on: push: @@ -10,8 +10,22 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 22 + cache: 'npm' + + - name: Install dependencies + run: | + npm ci + + - name: Build Vite frontend + run: | + npm run build - name: Setup SSH env: @@ -20,26 +34,28 @@ jobs: mkdir -p ~/.ssh echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa - eval "$(ssh-agent -s)" - ssh-add ~/.ssh/id_rsa - ssh-keyscan git.raphix.fr >> ~/.ssh/known_hosts + ssh-keyscan -H alpha.raphix.fr >> ~/.ssh/known_hosts - - name: Build Frontend + - name: Deploy frontend to alpha run: | - npm ci - npm run build - - - name: Deploy Frontend - run: | - scp -r dist/* raphix@alpha:/home/gitlab-ci/frontend/dist/ - ssh -o StrictHostKeyChecking=no raphix@alpha << 'EOF' - sudo su - gitlab-ci -c ' + ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr << 'EOF' + sudo su - gitlab-ci << 'INNER_EOF' set -e - echo "[Frontend-Deploy] - Stage - Déploiement - START" - # Assure les permissions - chown -R gitlab-ci:gitlab-ci /home/gitlab-ci/frontend/dist + echo "[Frontend-Deploy] - START" - echo "[Frontend-Deploy] - Stage - Déploiement - END" - ' + # Nettoyage ancien build + rm -rf /home/gitlab-ci/chopin-frontend/dist + rm -rf /home/gitlab-ci/chopin-frontend/node_modules + + # Copier les fichiers build depuis le workspace CI + mkdir -p /home/gitlab-ci/chopin-frontend + rsync -av --delete /workspace/subsonics/chopin-frontend/dist/ /home/gitlab-ci/chopin-frontend/dist/ + + # Reinstaller les dépendances pour npm scripts côté serveur si nécessaire + cd /home/gitlab-ci/chopin-frontend + npm ci --omit=dev + + echo "[Frontend-Deploy] - END" + INNER_EOF EOF