Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(ci): retry transient errors in deploy check-wait gate (#62733)

Raúl Negrón-Otero4034b4191939
diff --git a/.github/actions/wait-for-check/action.yml b/.github/actions/wait-for-check/action.yml
new file mode 100644
index 000000000000..d0bed7950a5a
--- /dev/null
+++ b/.github/actions/wait-for-check/action.yml
@@ -0,0 +1,82 @@
+name: 'Wait for check'
+description: >-
+ Poll a commit for a named GitHub Actions check run until it completes, tolerating
+ transient API errors. First-party replacement for fountainhead/action-wait-for-check,
+ which crashed on a single bad API response and runs on a deprecated Node runtime.
+inputs:
+ token:
+ description: 'GitHub token used to read check runs'
+ required: true
+ checkName:
+ description: 'Exact name of the check run to wait for'
+ required: true
+ ref:
+ description: 'Commit SHA whose check runs are polled'
+ required: true
+ timeoutSeconds:
+ description: 'Give up after this many seconds'
+ required: false
+ default: '3600'
+ intervalSeconds:
+ description: 'Seconds between polls'
+ required: false
+ default: '30'
+outputs:
+ conclusion:
+ description: >-
+ Conclusion of the completed check (success, failure, cancelled, ...).
+ 'timed_out' if the check did not complete before the timeout.
+ value: ${{ steps.poll.outputs.conclusion }}
+runs:
+ using: 'composite'
+ steps:
+ - name: Poll for check run
+ id: poll
+ shell: bash
+ env:
+ GH_TOKEN: ${{ inputs.token }}
+ CHECK_NAME: ${{ inputs.checkName }}
+ REF: ${{ inputs.ref }}
+ TIMEOUT_SECONDS: ${{ inputs.timeoutSeconds }}
+ INTERVAL_SECONDS: ${{ inputs.intervalSeconds }}
+ run: |
+ # Fail fast on caller mistakes: composite `required: true` is not
+ # runner-enforced, and bad numbers would otherwise degrade into a
+ # silent no-wait or an API busy-loop.
+ if ! [[ "$CHECK_NAME" && "$REF" && "$TIMEOUT_SECONDS" =~ ^[0-9]+$ && "$INTERVAL_SECONDS" =~ ^[1-9][0-9]*$ ]]; then
+ echo "::error::wait-for-check: invalid inputs: checkName='$CHECK_NAME' ref='$REF' timeoutSeconds='$TIMEOUT_SECONDS' intervalSeconds='$INTERVAL_SECONDS'"
+ exit 1
+ fi
+ # A transient API error must not fail the wait — log it and retry
+ # until the deadline. Callers decide what a timed_out conclusion means.
+ conclusion=""
+ while [ "$SECONDS" -lt "$TIMEOUT_SECONDS" ]; do
+ # Server-side check_name filtering narrows the response; the jq
+ # re-checks the name so a filter regression can't select the wrong
+ # check, and only GitHub Actions' own check counts — other apps
+ # (e.g. CI mirrors) may report checks under the same name.
+ # filter=latest dedupes re-runs only within a check suite, and the
+ # same SHA can carry same-name runs from several suites (one per
+ # workflow run), so take the newest run (check run IDs are
+ # monotonic) and report it only once it completes — an older
+ # completed run must not mask a newer one still in flight.
+ if conclusion=$(gh api -X GET "repos/${GITHUB_REPOSITORY}/commits/${REF}/check-runs" \
+ -f check_name="$CHECK_NAME" -f filter=latest \
+ --jq '[.check_runs[] | select(.name == env.CHECK_NAME and .app.slug == "github-actions")] | max_by(.id) | select(.status == "completed") | .conclusion // empty'); then
+ if [ -n "$conclusion" ]; then
+ break
+ fi
+ echo "Check \"$CHECK_NAME\" has not completed yet; retrying in ${INTERVAL_SECONDS}s..."
+ else
+ conclusion=""
+ echo "GitHub API error while looking up check \"$CHECK_NAME\"; retrying in ${INTERVAL_SECONDS}s..."
+ fi
+ remaining=$(( TIMEOUT_SECONDS - SECONDS ))
+ if [ "$remaining" -lt 1 ]; then
+ break
+ fi
+ sleep "$(( remaining < INTERVAL_SECONDS ? remaining : INTERVAL_SECONDS ))"
+ done
+ conclusion="${conclusion:-timed_out}"
+ echo "Check \"$CHECK_NAME\" conclusion: $conclusion"
+ echo "conclusion=$conclusion" >> "$GITHUB_OUTPUT"
diff --git a/.github/workflows/ci-hobby.yml b/.github/workflows/ci-hobby.yml
index df043f4013f1..3756dbd40eaf 100644
--- a/.github/workflows/ci-hobby.yml
+++ b/.github/workflows/ci-hobby.yml
@@ -239,15 +239,19 @@ jobs:
});
fs.appendFileSync(process.env.GITHUB_OUTPUT, `deployment-id=${deployment.id}\n`);
+ - name: Check out .github for local actions
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout: .github
- name: Wait for container image build to complete
- uses: fountainhead/action-wait-for-check@5a908a24814494009c4bb27c242ea38c93c593be # v1.2.0
+ uses: ./.github/actions/wait-for-check
id: wait-for-image
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: Build Docker image
ref: ${{ github.event.pull_request.head.sha }}
- timeoutSeconds: 3600
- intervalSeconds: 30
+ timeoutSeconds: '3600'
+ intervalSeconds: '30'
- name: Update comment - Docker build failed
if: always() && steps.check-preview.outputs.preview == 'true' && steps.wait-for-image.outputs.conclusion != 'success'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
diff --git a/.github/workflows/container-images-cd.yml b/.github/workflows/container-images-cd.yml
index b02724052d32..5bdc378a3820 100644
--- a/.github/workflows/container-images-cd.yml
+++ b/.github/workflows/container-images-cd.yml
@@ -142,14 +142,13 @@ jobs:
# (ci-backend.yml runs in parallel on the same commit) — we only hold the
# deploy *dispatch* to Charts until this commit's backend suite is green.
# A stale merge once shipped a red master commit to prod because the dispatch
- # fired regardless of test results; this is the backstop. Cross-workflow
- # check-waiting on the same SHA mirrors the pattern in ci-hobby.yml.
+ # fired regardless of test results; this is the backstop.
- name: Wait for backend/product checks to pass
# Only gate automatic master pushes. A manual workflow_dispatch is the
# break-glass: it skips the wait so an operator can force a deploy.
if: github.event_name == 'push'
id: wait-for-backend
- uses: fountainhead/action-wait-for-check@5a908a24814494009c4bb27c242ea38c93c593be # v1.2.0
+ uses: ./.github/actions/wait-for-check
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: Django Tests Pass
@@ -157,8 +156,8 @@ jobs:
# Must outlast the longest backend job (django tests: 45m in
# ci-backend.yml) plus its start lag, so a slow-but-green check
# still reports before we give up and block the deploy.
- timeoutSeconds: 3300
- intervalSeconds: 30
+ timeoutSeconds: '3300'
+ intervalSeconds: '30'
- name: Block deploy if backend/product checks did not pass
if: github.event_name == 'push'