Repository navigation
Description
Analysis
actions/setup-cli takes a github-token input and exports it as GH_TOKEN. In install.sh (identical to install-gh-aw.sh on main) the token is used in one place only: the releases?per_page=… API call that resolves a major-version channel such as v1 (RELEASES_CURL_ARGS, around lines 225-231). Every other request is anonymous:
| Request | Where | Token sent |
|---|---|---|
| Releases API, channel resolution | RELEASES_CURL_ARGS |
yes |
releases/latest API, tag fallback |
curl -sLf … /releases/latest |
no |
Binary, releases/download/<tag>/<platform> |
download_binary_with_retry |
no |
checksums.txt |
download_checksums_with_retry |
no |
install.ps1 already does it the other way round: $GitHubHeaders carries Authorization and is passed to Invoke-WebRequest for the binary and the checksums too. So the two installers differ.
Why it matters
Observed on 2026-11-09 (UTC), while githubstatus.com listed "Increased timeouts due to surge in anonymous users": a workflow pinned to version: v1.0.1 failed in setup-cli after three attempts, all curl: (22) … 504, in about 6 seconds:
curl: (22) The requested URL returned error: 504
[WARNING] Download attempt 1 failed. Retrying in 2s...
curl: (22) The requested URL returned error: 504
[WARNING] Download attempt 2 failed. Retrying in 4s...
curl: (22) The requested URL returned error: 504
[ERROR] Failed to download binary from https://github.com/github/gh-aw/releases/download/v1.0.1/linux-amd64 after 3 attempts
Passing a token to the action did not help, because for a pinned version the token was never sent. Callers that supply a PAT or an app token for exactly this reason cannot get authenticated downloads from the action.
Not verified: that an authenticated request avoids a 504 during an incident. The incident named anonymous traffic, and the 60 requests/hour anonymous limit applies per runner IP, so sending the token is the cheapest mitigation to try, and it matches install.ps1.
Implementation plan
Please implement the following changes.
actions/setup-cli/install.shandinstall-gh-aw.sh(keep the two identical):- Build one array
AUTH_CURL_ARGSafter the argument parsing: empty whenGH_TOKENis unset, otherwise(-H "Authorization: Bearer $GH_TOKEN"). Build the header the wayRELEASES_CURL_ARGSdoes today. - Use it in
download_binary_with_retry,download_checksums_with_retry, and thereleases/latestrequest. - Do not add
--location-trusted. curl then drops theAuthorizationheader whengithub.comredirects torelease-assets.githubusercontent.com, so the token never reaches the asset host. - Fall back to an anonymous request when the authenticated one fails. The default
github-tokenis${{ github.token }}, which is not valid on github.com when the workflow runs on GHES or GHE.com, so an authenticated request there can answer 401 where the anonymous one succeeds today. Per download: try with the header up toMAX_RETRIES, then try once without it and print aprint_warningthat says the token was rejected.
- Build one array
actions/setup-cli/install.ps1andinstall-gh-aw.ps1: add the same anonymous fallback toInvoke-DownloadWithRetryand the checksums download, which already send$GitHubHeaders. No other change.- Tests in
scripts/test-install-script.sh(run throughactions/setup-cli/install_test.sh), using the existingfixture_bin/curlshim and itshas_headerhelper:- With
GH_TOKEN=test-token, a pinned version sendsAuthorization: Bearer test-tokenon the binary and the checksums requests. - Without
GH_TOKEN, no request carries anAuthorizationheader. - When the shim answers 401 to any request that carries the header, the install still succeeds and prints the fallback warning.
- The
latestpath sends the header on thereleases/latestlookup as well.
- With
- Docs (
actions/setup-cli/README.md,github-token, lines 84-89 and 187-196): say the token is used forghoperations, API calls and release asset downloads, that an expired or foreign-instance token falls back to an anonymous download, and that a github.com token is needed on GHES / GHE.com to get any benefit. - Follow the guidelines: run
make agent-finishand add a changeset if the repository asks for one foractions/.
Acceptance criteria
bash actions/setup-cli/install_test.shpasses with the four new cases.diff install-gh-aw.sh actions/setup-cli/install.shis empty.- On a pinned version with
GH_TOKENset, everycurlagainstgithub.comcarries the header, and none follows a redirect with it (--location-trustedis absent).
Activity