53 lines
1.6 KiB
YAML
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"
|