Skip to content

ci: retry gh auth login to survive transient GitHub API 5xx - #52

Draft
Sbussiso wants to merge 1 commit into
masterfrom
ci-fix/32042892282
Draft

ci: retry gh auth login to survive transient GitHub API 5xx#52
Sbussiso wants to merge 1 commit into
masterfrom
ci-fix/32042892282

Conversation

@Sbussiso

Copy link
Copy Markdown
Contributor

Root cause — run #576 (32042892282)

The Sync Docs workflow failed at the Auth GitHub CLI step:

gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
→ error retrieving current user: HTTP 503: No server is currently available
  to service your request. (https://api.github.com/graphql)

This is a transient GitHub-side API degradation (HTTP 503 on the GraphQL endpoint), not a token, script, or repo problem. gh auth login calls the GitHub API to validate the token, and that validation call was rejected because GitHub itself was briefly unavailable. The hourly cron run was killed entirely by this one momentary blip — confirmed by the fact that my own gh repo clone of this repo hit the identical 503 and needed a retry to succeed.

Fix

Wrap gh auth login in a bounded retry loop (5 attempts, linear backoff of 5/10/15/20/25s) so a momentary GitHub API 5xx no longer fails the whole sync. The token is unchanged; we just tolerate GitHub being briefly flaky.

       - name: Auth GitHub CLI
-        run: gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
+        run: |
+          for attempt in 1 2 3 4 5; do
+            if gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"; then
+              echo "gh auth succeeded on attempt ${attempt}"
+              exit 0
+            fi
+            echo "gh auth attempt ${attempt} failed; retrying in $((attempt * 5))s..."
+            sleep $((attempt * 5))
+          done
+          echo "::error::gh auth login failed after 5 attempts (GitHub API likely degraded)"
+          exit 1

Why a draft

Opened as a draft so a human can sanity-check before the hourly cron picks it up. If you would rather just re-run the failed job (it self-heals next cron), no PR is needed — but this hardens the workflow against the next 503.

Triage ref: run 32042892282, commit 196bf4b.

The Auth GitHub CLI step calls the GitHub API to validate the token,
which failed in run #576 with a transient HTTP 503 ('No server is
currently available') during a GitHub-side degradation. This killed
the entire hourly docs sync even though the token and script were fine.

Wrap gh auth login in a bounded retry loop (5 attempts, linear backoff)
so a momentary GitHub API blip no longer fails the run.

Fixes SourceBox-LLC/sentinel-website run 32042892282.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants