46 lines
1.1 KiB
YAML
46 lines
1.1 KiB
YAML
name: Deploy API Ubigeo
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Deploy al VPS via SSH
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: 158.220.106.131
|
|
username: root
|
|
password: ${{ secrets.VPS_PASSWORD }}
|
|
script: |
|
|
set -e
|
|
cd /home/deployer/api-ubigeo || (mkdir -p /home/deployer/api-ubigeo && cd /home/deployer/api-ubigeo)
|
|
|
|
# Pull o clone
|
|
if [ -d ".git" ]; then
|
|
git pull origin main
|
|
else
|
|
git clone https://github.com/${{ github.repository }} .
|
|
fi
|
|
|
|
# Build imagen
|
|
docker build -t ubigeo-api:latest .
|
|
|
|
# Deploy con compose
|
|
docker compose -f docker-compose.production.yml up -d --force-recreate api
|
|
|
|
# Ejecutar migraciones
|
|
docker exec ubigeo-api npx prisma migrate deploy
|
|
|
|
# Verificar health
|
|
sleep 10
|
|
curl -f http://localhost:3200/api/v1/health || exit 1
|
|
|
|
echo "✅ Deploy exitoso"
|