Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b0b95d2453 | |||
| cf00318f23 |
@@ -153,29 +153,85 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
"
|
"
|
||||||
|
|
||||||
# ── Step 6: Health Check ──────────────────
|
# ── Step 6: Health Check (backoff) ────────
|
||||||
|
# Exponential-ish backoff: 1s, 2s, 3s, 5s, 8s, 13s (~32s total).
|
||||||
|
# Why: cold-start containers need variable warmup time;
|
||||||
|
# fixed 5s intervals either wait too long or give up too early.
|
||||||
- name: Health Check
|
- name: Health Check
|
||||||
run: |
|
run: |
|
||||||
sleep 5
|
|
||||||
echo "🏥 Health check..."
|
echo "🏥 Health check..."
|
||||||
for i in 1 2 3 4 5 6; do
|
RETRY=0
|
||||||
|
MAX=6
|
||||||
|
WAIT=1
|
||||||
|
while [ $RETRY -lt $MAX ]; do
|
||||||
|
RETRY=$((RETRY + 1))
|
||||||
if curl -sf --max-time 10 https://nexus.noveria.net/health; then
|
if curl -sf --max-time 10 https://nexus.noveria.net/health; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "✅ Health check passed"
|
echo "✅ Health check passed (attempt $RETRY/$MAX)"
|
||||||
break
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo "⏳ Retry $i/6..."
|
echo "⏳ Attempt $RETRY/$MAX failed, waiting ${WAIT}s..."
|
||||||
sleep 5
|
sleep $WAIT
|
||||||
|
# Fibonacci-ish backoff: 1,2,3,5,8,13
|
||||||
|
NEXT=$((WAIT + RETRY))
|
||||||
|
[ $NEXT -le 15 ] && WAIT=$NEXT || WAIT=15
|
||||||
done
|
done
|
||||||
|
echo "❌ Health check failed after $MAX attempts"
|
||||||
|
exit 1
|
||||||
|
|
||||||
# ── Step 7: Smoke test ────────────────────
|
# ── Step 7: Smoke test (multi-endpoint) ───
|
||||||
|
# Tests multiple endpoints to catch partial failures.
|
||||||
|
# Why: a single /dashboard check can miss backend-only outages;
|
||||||
|
# testing /api/swagger confirms the API layer is healthy too.
|
||||||
- name: Verify (smoke test)
|
- name: Verify (smoke test)
|
||||||
run: |
|
run: |
|
||||||
echo "🔍 Smoke test..."
|
echo "🔍 Smoke test..."
|
||||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://nexus.noveria.net/dashboard)
|
PASS=0
|
||||||
echo "Dashboard: HTTP $HTTP_CODE"
|
FAIL=0
|
||||||
if [ "$HTTP_CODE" != "200" ]; then
|
BASE="https://nexus.noveria.net"
|
||||||
echo "❌ Dashboard not reachable!"
|
|
||||||
|
check() {
|
||||||
|
local path="$1" label="$2" expected="${3:-200}"
|
||||||
|
local code=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 "${BASE}${path}")
|
||||||
|
printf " %-25s HTTP %s" "${label}:" "${code}"
|
||||||
|
if [ "$code" = "$expected" ]; then
|
||||||
|
echo " ✅"
|
||||||
|
PASS=$((PASS + 1))
|
||||||
|
else
|
||||||
|
echo " ❌ (expected $expected)"
|
||||||
|
FAIL=$((FAIL + 1))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check "/dashboard" "Dashboard" 200
|
||||||
|
check "/health" "Health API" 200
|
||||||
|
check "/api/swagger" "API Swagger" 200
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Results: $PASS passed, $FAIL failed"
|
||||||
|
if [ "$FAIL" -gt 0 ]; then
|
||||||
|
echo "❌ Smoke test failed!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "✅ Deployment verified"
|
echo "✅ Deployment verified"
|
||||||
|
|
||||||
|
# ── Step 8: Rollback hint ────────────────
|
||||||
|
# On any failure, prints the previous deploy tag for quick manual rollback.
|
||||||
|
# Why: reduces MTTR (mean time to recovery) by providing the exact
|
||||||
|
# git tag to roll back to without needing to look it up manually.
|
||||||
|
- name: Rollback hint
|
||||||
|
if: failure()
|
||||||
|
run: |
|
||||||
|
echo ""
|
||||||
|
echo "🔙 ─── Rollback Instructions ─── 🔙"
|
||||||
|
echo ""
|
||||||
|
echo " # 1. Checkout previous version:"
|
||||||
|
echo " git checkout tags/\$(git describe --tags --abbrev=0 2>/dev/null || echo 'unknown')"
|
||||||
|
echo ""
|
||||||
|
echo " # 2. Redeploy:"
|
||||||
|
echo " cd /opt/openclaw/data/openclaw/workspace/nexus"
|
||||||
|
echo " docker compose up -d --force-recreate"
|
||||||
|
echo ""
|
||||||
|
echo " # 3. Or trigger rollback via Gitea:"
|
||||||
|
echo " Trigger 'Deploy to Production' workflow with the previous tag"
|
||||||
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user