49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
name: Frontend Deployment
 | 
						||
 | 
						||
on:
 | 
						||
  push:
 | 
						||
    branches:
 | 
						||
      - main
 | 
						||
 | 
						||
jobs:
 | 
						||
  deploy-frontend:
 | 
						||
    runs-on: ubuntu-latest
 | 
						||
 | 
						||
    steps:
 | 
						||
      # 1️⃣ Checkout du code
 | 
						||
      - name: Checkout repository
 | 
						||
        uses: actions/checkout@v3
 | 
						||
 | 
						||
      # 2️⃣ Setup Node.js (ici Node 22)
 | 
						||
      - name: Setup Node.js
 | 
						||
        uses: actions/setup-node@v3
 | 
						||
        with:
 | 
						||
          node-version: '22'
 | 
						||
 | 
						||
      # 3️⃣ Installer les dépendances et builder le frontend
 | 
						||
      - name: Build frontend
 | 
						||
        run: |
 | 
						||
          cd chopin-frontend
 | 
						||
          npm install --omit=dev
 | 
						||
          npm run build
 | 
						||
 | 
						||
      # 4️⃣ Setup SSH pour la connexion vers alpha
 | 
						||
      - 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 alpha.raphix.fr >> ~/.ssh/known_hosts
 | 
						||
 | 
						||
      # 5️⃣ Copier le build sur alpha
 | 
						||
      - name: Deploy frontend to Alpha
 | 
						||
        run: |
 | 
						||
          rsync -av --delete chopin-frontend/dist/ raphix@alpha.raphix.fr:/home/gitlab-ci/chopin-frontend/dist/
 | 
						||
 | 
						||
      # 6️⃣ Ajuster permissions sur alpha si nécessaire
 | 
						||
      - name: Set permissions on Alpha
 | 
						||
        run: |
 | 
						||
          ssh raphix@alpha.raphix.fr "sudo chown -R gitlab-ci:gitlab-ci /home/gitlab-ci/chopin-frontend/dist"
 |