feat: Adiciona nos services de dashboard e genalogia otimizações de p… #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy API BUFFS | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout código | |
| uses: actions/checkout@v4 | |
| # --- BUILD LOCAL --- | |
| - name: Configurar Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Instalar dependências | |
| run: npm ci | |
| - name: Build do projeto | |
| run: npm run build | |
| # --- DEPLOY --- | |
| - name: Parar aplicação no EC2 | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ec2-user | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| port: 22 | |
| script: | | |
| pm2 stop dsm5-buffs-api || true | |
| - name: Copiar arquivos buildados | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ec2-user | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| port: 22 | |
| source: 'dist/*,package.json,package-lock.json,ecosystem.config.js' | |
| target: '/home/ec2-user/dsm5-buffs-api/' | |
| strip_components: 0 | |
| - name: Instalar dependências e reiniciar | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ec2-user | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| port: 22 | |
| script: | | |
| cd /home/ec2-user/dsm5-buffs-api | |
| # Instalar apenas dependências de produção | |
| npm ci --omit=dev | |
| # Iniciar/reiniciar com o ecosystem config | |
| pm2 startOrRestart ecosystem.config.js --update-env | |
| # Salvar configuração do PM2 | |
| pm2 save | |
| # Mostrar status | |
| pm2 status |