ci: fix smoke test with redirect follow and range check
CI/CD / deploy (push) Failing after 1m36s Details

Use -sSL for curl, range-based HTTP code check (2xx-3xx pass),
and increase timeout to 30s.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-04-01 12:23:23 -07:00
parent c63fe08739
commit 9bffa08215
1 changed files with 6 additions and 5 deletions

View File

@ -51,15 +51,16 @@ jobs:
- name: Smoke test
run: |
sleep 10
HTTP_CODE=$(curl -sS -o /dev/null -w "%{http_code}" --max-time 15 https://conviction.jeffemmett.com/ 2>/dev/null || echo "000")
if [ "$HTTP_CODE" != "200" ]; then
echo "Smoke test failed — rolling back"
sleep 15
HTTP_CODE=$(curl -sSL -o /dev/null -w "%{http_code}" --max-time 30 https://conviction.jeffemmett.com/ 2>/dev/null || echo "000")
if [ "$HTTP_CODE" -lt 200 ] || [ "$HTTP_CODE" -ge 400 ]; then
echo "Smoke test failed (HTTP $HTTP_CODE) — rolling back"
ROLLBACK_TAG=$(ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key root@${{ secrets.DEPLOY_HOST }} "cat /opt/websites/conviction-voting-demo/.rollback-tag 2>/dev/null")
if [ -n "$ROLLBACK_TAG" ]; then
ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key root@${{ secrets.DEPLOY_HOST }} \
"cd /opt/websites/conviction-voting-demo && IMAGE_TAG=$ROLLBACK_TAG docker compose up -d --no-build"
echo "Rolled back to $ROLLBACK_TAG"
fi
exit 1
fi
echo "Smoke test passed"
echo "Smoke test passed (HTTP $HTTP_CODE)"