62 lines
1.6 KiB
YAML
62 lines
1.6 KiB
YAML
name: Frontend Deployment
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
deploy-frontend:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- 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:
|
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
|
chmod 600 ~/.ssh/id_rsa
|
|
ssh-keyscan -H alpha.raphix.fr >> ~/.ssh/known_hosts
|
|
|
|
- name: Deploy frontend to alpha
|
|
run: |
|
|
ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr << 'EOF'
|
|
sudo su - gitlab-ci << 'INNER_EOF'
|
|
set -e
|
|
|
|
echo "[Frontend-Deploy] - START"
|
|
|
|
# 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
|