ci: promote revision only after healthy deploy
This commit is contained in:
@@ -169,7 +169,7 @@ jobs:
|
||||
- name: Sync Files to Production
|
||||
run: |
|
||||
set -euo pipefail
|
||||
printf "%s\n" "${{ github.sha }}" > REVISION
|
||||
printf "%s\n" "${{ github.sha }}" > DEPLOY_TARGET_REVISION
|
||||
rsync -az --delete --delay-updates -e "ssh -i ~/.ssh/id_deploy" \
|
||||
--exclude='.git/' \
|
||||
--exclude='.gitea/' \
|
||||
@@ -237,9 +237,51 @@ jobs:
|
||||
fi
|
||||
done
|
||||
|
||||
TARGET_REVISION="$(cat DEPLOY_TARGET_REVISION)"
|
||||
if [ -z "$TARGET_REVISION" ]; then
|
||||
echo "[Deploy] Missing DEPLOY_TARGET_REVISION; aborting before restart."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker compose -f docker-compose.prod.yml config -q
|
||||
docker compose -f docker-compose.prod.yml build --pull
|
||||
docker compose -f docker-compose.prod.yml up -d --remove-orphans
|
||||
docker compose -f docker-compose.prod.yml up -d --remove-orphans --force-recreate \
|
||||
fifa2026-seed \
|
||||
fifa2026-backend \
|
||||
fifa2026-odds-worker \
|
||||
fifa2026-news-worker \
|
||||
fifa2026-agent-review-worker \
|
||||
fifa2026-calendar-cache-worker \
|
||||
fifa2026-fixtures-worker \
|
||||
fifa2026-alerts \
|
||||
fifa2026-web
|
||||
|
||||
echo "[Deploy] Waiting for backend health."
|
||||
for attempt in $(seq 1 30); do
|
||||
if curl -fsS http://127.0.0.1:8000/health >/dev/null; then
|
||||
break
|
||||
fi
|
||||
if [ "$attempt" -eq 30 ]; then
|
||||
echo "[Deploy] Backend health check failed; REVISION will not be promoted."
|
||||
exit 1
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
|
||||
echo "[Deploy] Waiting for frontend health."
|
||||
for attempt in $(seq 1 30); do
|
||||
if curl -fsS http://127.0.0.1:3108 >/dev/null; then
|
||||
break
|
||||
fi
|
||||
if [ "$attempt" -eq 30 ]; then
|
||||
echo "[Deploy] Frontend health check failed; REVISION will not be promoted."
|
||||
exit 1
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
|
||||
printf "%s\n" "$TARGET_REVISION" > REVISION
|
||||
rm -f DEPLOY_TARGET_REVISION
|
||||
docker image prune -f
|
||||
echo "[Deploy] Deployment completed successfully."
|
||||
echo "[Deploy] Deployment completed successfully: $TARGET_REVISION"
|
||||
DEPLOY_SCRIPT
|
||||
|
||||
Reference in New Issue
Block a user