name: Deploy to VPS on: push: branches: - main workflow_dispatch: jobs: build: runs-on: ubuntu-latest steps: - uses: https://github.com/actions/checkout@v4 - uses: https://github.com/actions/setup-node@v4 with: node-version: "20" - run: npm ci --prefer-offline - run: npm run build env: VITE_API_URL: https://esameits24-26backend.andreavillari.it - uses: https://github.com/actions/upload-artifact@v4 with: name: frontend-dist path: dist/ retention-days: 1 deploy: needs: build runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: https://github.com/actions/checkout@v4 - uses: https://github.com/actions/download-artifact@v4 with: name: frontend-dist path: dist - uses: https://github.com/appleboy/scp-action@v0.1.7 with: host: ${{ secrets.VPS_HOST }} username: ${{ secrets.VPS_USER }} key: ${{ secrets.VPS_SSH_KEY }} source: "dist" target: "/root/esameits24-26frontend" overwrite: true - uses: https://github.com/appleboy/ssh-action@v1.0.3 with: host: ${{ secrets.VPS_HOST }} username: ${{ secrets.VPS_USER }} key: ${{ secrets.VPS_SSH_KEY }} command_timeout: 10m script: | set -e echo "=== START $(date -Iseconds) ===" cd /root/esameits24-26frontend git pull --ff-only if [ ! -d dist ] || [ -z "$(ls -A dist 2>/dev/null)" ]; then echo "ERRORE: dist/ mancante o vuota dopo SCP" exit 1 fi echo "=== DOCKER BUILD RUNTIME $(date -Iseconds) ===" docker compose -f docker-compose.prod.yml --progress plain up -d --build echo "=== END $(date -Iseconds) ===" docker compose -f docker-compose.prod.yml ps echo "DEPLOY COMPLETE"