Skip to content

install-gh-aw.sh / setup-cli: send GH_TOKEN with the binary and checksums downloads, not only the releases API #76167

Done

Description

@UncleBats

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.

  1. actions/setup-cli/install.sh and install-gh-aw.sh (keep the two identical):
    • Build one array AUTH_CURL_ARGS after the argument parsing: empty when GH_TOKEN is unset, otherwise (-H "Authorization: Bearer $GH_TOKEN"). Build the header the way RELEASES_CURL_ARGS does today.
    • Use it in download_binary_with_retry, download_checksums_with_retry, and the releases/latest request.
    • Do not add --location-trusted. curl then drops the Authorization header when github.com redirects to release-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-token is ${{ 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 to MAX_RETRIES, then try once without it and print a print_warning that says the token was rejected.
  2. actions/setup-cli/install.ps1 and install-gh-aw.ps1: add the same anonymous fallback to Invoke-DownloadWithRetry and the checksums download, which already send $GitHubHeaders. No other change.
  3. Tests in scripts/test-install-script.sh (run through actions/setup-cli/install_test.sh), using the existing fixture_bin/curl shim and its has_header helper:
    • With GH_TOKEN=test-token, a pinned version sends Authorization: Bearer test-token on the binary and the checksums requests.
    • Without GH_TOKEN, no request carries an Authorization header.
    • When the shim answers 401 to any request that carries the header, the install still succeeds and prints the fallback warning.
    • The latest path sends the header on the releases/latest lookup as well.
  4. Docs (actions/setup-cli/README.md, github-token, lines 84-89 and 187-196): say the token is used for gh operations, 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.
  5. Follow the guidelines: run make agent-finish and add a changeset if the repository asks for one for actions/.

Acceptance criteria

  • bash actions/setup-cli/install_test.sh passes with the four new cases.
  • diff install-gh-aw.sh actions/setup-cli/install.sh is empty.
  • On a pinned version with GH_TOKEN set, every curl against github.com carries the header, and none follows a redirect with it (--location-trusted is absent).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions