ops: add post-deploy verification script and add to CI/CD workflow
All checks were successful
Deploy to Production / Deploy to Server (push) Successful in 1m35s

- scripts/verify-deploy.sh: checks container health, /health endpoint, and Stripe checkout
- .forgejo/workflows/deploy.yml: runs verify-deploy.sh after successful deploy
This commit is contained in:
DocFast Bot 2026-02-17 11:51:36 +00:00
parent f5cea97adf
commit 73fba68320
2 changed files with 43 additions and 0 deletions

View file

@ -85,6 +85,10 @@ jobs:
sleep 5
done
# Run post-deploy verification
echo "🔍 Running post-deploy verification..."
bash scripts/verify-deploy.sh
# Cleanup old rollback images (keep last 5)
echo "🧹 Cleaning up old rollback images..."
docker images --format "table {{.Repository}}:{{.Tag}}" | grep "docfast-docfast:rollback-" | tail -n +6 | awk '{print $1":"$2}' | xargs -r docker rmi || true

39
scripts/verify-deploy.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash
# Post-deploy verification for DocFast
set -e
echo "⏳ Waiting for container to be healthy..."
for i in $(seq 1 30); do
STATUS=$(docker inspect --format='{{.State.Health.Status}}' docfast-docfast-1 2>/dev/null || echo "not found")
if [ "$STATUS" = "healthy" ]; then
echo "✅ Container healthy"
break
fi
if [ $i -eq 30 ]; then
echo "❌ Container not healthy after 30s"
exit 1
fi
sleep 1
done
echo "🔍 Checking health endpoint..."
HEALTH=$(curl -sf http://localhost:3100/health | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['status'])" 2>/dev/null)
if [ "$HEALTH" != "ok" ]; then
echo "❌ Health check failed"
exit 1
fi
echo "✅ Health OK"
echo "🔍 Checking Stripe checkout..."
CHECKOUT=$(curl -sf -X POST http://localhost:3100/v1/billing/checkout -H "Content-Type: application/json" 2>&1)
if echo "$CHECKOUT" | grep -q '"url"'; then
echo "✅ Stripe checkout working"
elif echo "$CHECKOUT" | grep -q 'STRIPE_SECRET_KEY'; then
echo "❌ STRIPE_SECRET_KEY not configured!"
exit 1
else
echo "⚠️ Checkout returned: $CHECKOUT"
fi
echo ""
echo "🎉 Deploy verification passed!"