Skip to content

Commit f0ab70d

Browse files
SirDarcanosclaude
andcommitted
Give a deploy time to reach the edge before checking it
Both health checks failed on a push where both deploys had succeeded. The API check started 0.1 seconds after wrangler returned and gave up 25 seconds later; minutes afterwards both endpoints answered correctly. They were racing Cloudflare putting the new version on the edge the runner happens to reach, not finding a broken deploy. Each now waits before its first attempt and keeps trying for two minutes, and prints what actually came back on every attempt. The previous version failed five times in a row while saying only "Attempt N failed", which gave nothing to diagnose from. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 2d43a45 commit f0ab70d

2 files changed

Lines changed: 22 additions & 13 deletions

File tree

‎.github/workflows/deploy-api.yml‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,20 @@ jobs:
4949
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
5050
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
5151

52+
# Waits before the first attempt and keeps trying for two minutes. Cloudflare needs a
53+
# moment to put a new version on every edge, and this check used to start a tenth of a
54+
# second after wrangler returned and give up 25 seconds later — failing a deploy that
55+
# had worked. Each attempt prints what came back, so a real failure says why.
5256
- name: Check the deployed API answers
5357
run: |
54-
for attempt in 1 2 3 4 5; do
55-
if curl -sf 'https://api.rollful.dev/v1/health' | grep -q '"status":"ok"'; then
56-
echo "Health check passed"
58+
for attempt in $(seq 1 12); do
59+
sleep 10
60+
body="$(curl -sS --max-time 10 'https://api.rollful.dev/v1/health' 2>&1 || true)"
61+
if printf '%s' "$body" | grep -q '"status":"ok"'; then
62+
echo "Health check passed on attempt $attempt"
5763
exit 0
5864
fi
59-
echo "Attempt $attempt failed, retrying"
60-
sleep 5
65+
echo "Attempt $attempt: $(printf '%s' "$body" | head -c 150)"
6166
done
62-
echo "::error::The deployed API did not answer /v1/health"
67+
echo "::error::The deployed API did not answer /v1/health within two minutes"
6368
exit 1

‎.github/workflows/deploy-site.yml‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,21 @@ jobs:
4545
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
4646

4747
# -L because /reference redirects to /reference/, which is how Astro builds it.
48+
#
49+
# Waits before the first attempt and keeps trying for two minutes. Cloudflare needs a
50+
# moment to put a new version on every edge, and this check used to start immediately
51+
# after wrangler returned and give up 25 seconds later — failing a deploy that had
52+
# worked. Each attempt prints what came back, so a real failure says why.
4853
- name: Check the deployed site answers
4954
run: |
50-
for attempt in 1 2 3 4 5; do
51-
page="$(curl -sfL 'https://rollful.dev/reference/' || true)"
55+
for attempt in $(seq 1 12); do
56+
sleep 10
57+
page="$(curl -sSL --max-time 10 'https://rollful.dev/reference/' 2>&1 || true)"
5258
if printf '%s' "$page" | grep -q 'data-spec="https://api.rollful.dev/openapi.json"'; then
53-
echo "Reference page served, pointing at the production API"
59+
echo "Reference page served on attempt $attempt, pointing at the production API"
5460
exit 0
5561
fi
56-
echo "Attempt $attempt failed, retrying"
57-
sleep 5
62+
echo "Attempt $attempt: $(printf '%s' "$page" | head -c 150)"
5863
done
59-
echo "::error::The deployed site did not serve /reference/ pointing at the production API"
60-
printf '%s' "$page" | head -c 500
64+
echo "::error::The deployed site did not serve /reference/ pointing at the production API within two minutes"
6165
exit 1

0 commit comments

Comments
 (0)