ci: add rollback on failed deploy
All checks were successful
Deploy API-Ubigeo / deploy (push) Successful in 10m35s

This commit is contained in:
Gianpierre Mio
2026-04-09 08:56:03 -05:00
parent c00fc2fbd6
commit 3ef332f073

View File

@@ -11,6 +11,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Backup current image
run: |
docker tag ubigeo-api:latest ubigeo-api:rollback 2>/dev/null || true
- name: Sync source
run: |
rsync -a --delete \
@@ -32,6 +36,8 @@ jobs:
docker compose -f docker-compose.production.yml up -d
- name: Health check
id: health
continue-on-error: true
run: |
echo "Waiting for API-Ubigeo to start..."
for i in $(seq 1 15); do
@@ -46,3 +52,13 @@ jobs:
echo "❌ Health check failed after 45s"
docker logs ubigeo-api --tail 50
exit 1
- name: Rollback on failure
if: steps.health.outcome == 'failure'
run: |
echo "❌ Deploy failed, rolling back..."
docker tag ubigeo-api:rollback ubigeo-api:latest 2>/dev/null || true
cd /home/deployer/api-ubigeo
docker compose -f docker-compose.production.yml up -d --force-recreate
echo "🔄 Rollback complete"
exit 1