esameits24-26frontend/.github/workflows/deploy.yml
AV77web a2ffd71452
Some checks failed
Deploy to VPS / build (push) Failing after 38s
Deploy to VPS / deploy (push) Has been skipped
modifiche a Dockerfile e inserito dockerfile.runtime
2026-07-14 16:15:32 +02:00

67 lines
2 KiB
YAML

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"