esameits24-26frontend/.github/workflows/deploy.yml
AV77web 662eb46067
All checks were successful
Deploy to VPS / deploy (push) Successful in 44s
Deploy: niente artifact v4, SCP dist dopo build CI
2026-07-14 16:19:29 +02:00

53 lines
1.6 KiB
YAML

name: Deploy to VPS
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: https://github.com/actions/checkout@v4
- uses: https://github.com/actions/setup-node@v4
with:
node-version: "20"
- name: Build frontend
run: npm ci --prefer-offline && npm run build
env:
VITE_API_URL: https://esameits24-26backend.andreavillari.it
- 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"