Analysis
In workflows that use a proxied / integrity-filtered (e.g. DIFC-style) pre-agent setup, environment variables for the GitHub CLI are often rewritten so GH_HOST (and sometimes related GITHUB_*_URL values) target a local proxy host, while the checked-out repository’s origin remote remains the canonical GitHub.com / GHES HTTPS host (as set by typical actions/checkout + tokenized remotes).
The generated PR checkout path then runs gh pr checkout <pr-number> with GH_HOST still pointing at the proxy. The GitHub CLI validates remotes against GH_HOST and exits with:
none of the git remotes configured for this repository correspond to the GH_HOST environment variable
So the job fails before normal agent execution, even when the repository, PR, and token are valid. The failure is environment normalization / step isolation, not token scope. It is also easy to misdiagnose as permissions, fork handling, or invalid PR metadata.
Summary
This issue asks that generated gh-aw workflows (and/or shared setup actions) normalize or scope environment for PR checkout so gh pr checkout sees GH_HOST / API URLs consistent with git remotes, or use a git-native checkout for same-repo heads where appropriate—without downstream consumers hand-editing compiled lockfiles after every compile.
Observed failure shape
Typical gh error:
none of the git remotes configured for this repository correspond to the GH_HOST environment variable
Logs may show GH_HOST set to a localhost / loopback hostname (or another non-canonical host) while git remote -v still shows the real GitHub instance host.
What appears to be happening
- Early steps start a proxy (or similar) and adjust
GH_HOST / related GITHUB_*_URL so gh traffic goes through the proxy.
- PR checkout runs
gh pr checkout while GH_HOST still reflects the proxy, but git remotes still reference the real GitHub server hostname.
gh refuses to proceed because no remote matches GH_HOST.
Minimal repro (shape)
Conditions
- Workflow uses a proxy / DIFC-style pre-agent
gh setup that sets GH_HOST to a local proxy host.
- The workspace
git remote still targets the normal GitHub.com or GHES host.
- The generated checkout step uses
gh pr checkout (by PR number).
Result
gh pr checkout exits non-zero with the message above; dependent steps do not run.
A minimal public repro could be a small workflow that sets GH_HOST to a synthetic localhost value before gh pr checkout, without relying on proprietary proxy details.
Why this matters
- PR-triggered agent workflows can fail very early despite valid PRs and working auth.
- Operators and automation often assume 403 / permissions or fork issues first; the fix is checkout-scoped env or checkout strategy.
- Consumers should not rely on permanent post-compile patches to injected YAML for this class of failure.
Suggested implementation plan (for maintainers / implementing agent)
-
Smallest / targeted (compiler or shared action)
Immediately before the generated PR checkout step, emit step-level env (or equivalent) so that step uses real instance values, for example:
- Derive
GH_HOST from GITHUB_SERVER_URL (strip scheme).
- Set
GITHUB_API_URL and GITHUB_GRAPHQL_URL to the non-proxied endpoints that match that instance for the checkout step only.
Then run gh pr checkout under that env. Do not rely on job-wide GITHUB_ENV alone if later steps still need proxy settings—prefer scoping to the checkout step.
-
Better isolation
Ensure proxy-specific GH_HOST / API overrides do not leak into steps that must align with normal git remotes (explicit step env, or explicit unset/override for checkout only).
-
Stronger long-term
For same-repository PR heads, prefer deterministic git fetch / git checkout of the head ref when safe, and reserve gh pr checkout for cross-repo / fork cases where it is required.
-
Tests / validation
Add a regression test or workflow fixture that simulates GH_HOST mismatch (e.g. localhost) before checkout and asserts the generated workflow or helper normalizes env or chooses a git-native path.
-
Observability (optional but helpful)
When webhook PR metadata is partial, concise logging of same-repo vs cross-repo checkout decisions (from API-resolved metadata) helps distinguish fork/cross-repo needs, metadata ambiguity, and proxy / GH_HOST mismatch.
Additional note (observability)
When webhook PR metadata is thin (e.g. missing head repo), checkout strategy may differ. Logging same-repo vs cross-repo decisions would help separate:
- true fork / cross-repo checkout needs
- metadata ambiguity
- proxy /
GH_HOST mismatch (this issue)
Expected outcome
Generated gh-aw workflows check out PR branches reliably in proxied / DIFC-style environments without requiring consumers to hand-patch compiled lockfiles after every compile.
Thanks for considering this — happy to help validate a fix against our setup if useful (in generic terms, without sharing private repository details).
Analysis
In workflows that use a proxied / integrity-filtered (e.g. DIFC-style) pre-agent setup, environment variables for the GitHub CLI are often rewritten so
GH_HOST(and sometimes relatedGITHUB_*_URLvalues) target a local proxy host, while the checked-out repository’soriginremote remains the canonical GitHub.com / GHES HTTPS host (as set by typicalactions/checkout+ tokenized remotes).The generated PR checkout path then runs
gh pr checkout <pr-number>withGH_HOSTstill pointing at the proxy. The GitHub CLI validates remotes againstGH_HOSTand exits with:So the job fails before normal agent execution, even when the repository, PR, and token are valid. The failure is environment normalization / step isolation, not token scope. It is also easy to misdiagnose as permissions, fork handling, or invalid PR metadata.
Summary
This issue asks that generated gh-aw workflows (and/or shared setup actions) normalize or scope environment for PR checkout so
gh pr checkoutseesGH_HOST/ API URLs consistent withgitremotes, or use a git-native checkout for same-repo heads where appropriate—without downstream consumers hand-editing compiled lockfiles after every compile.Observed failure shape
Typical
gherror:Logs may show
GH_HOSTset to a localhost / loopback hostname (or another non-canonical host) whilegit remote -vstill shows the real GitHub instance host.What appears to be happening
GH_HOST/ relatedGITHUB_*_URLsoghtraffic goes through the proxy.gh pr checkoutwhileGH_HOSTstill reflects the proxy, butgitremotes still reference the real GitHub server hostname.ghrefuses to proceed because no remote matchesGH_HOST.Minimal repro (shape)
Conditions
ghsetup that setsGH_HOSTto a local proxy host.gitremote still targets the normal GitHub.com or GHES host.gh pr checkout(by PR number).Result
gh pr checkoutexits non-zero with the message above; dependent steps do not run.A minimal public repro could be a small workflow that sets
GH_HOSTto a synthetic localhost value beforegh pr checkout, without relying on proprietary proxy details.Why this matters
Suggested implementation plan (for maintainers / implementing agent)
Smallest / targeted (compiler or shared action)
Immediately before the generated PR checkout step, emit step-level
env(or equivalent) so that step uses real instance values, for example:GH_HOSTfromGITHUB_SERVER_URL(strip scheme).GITHUB_API_URLandGITHUB_GRAPHQL_URLto the non-proxied endpoints that match that instance for the checkout step only.Then run
gh pr checkoutunder that env. Do not rely on job-wideGITHUB_ENValone if later steps still need proxy settings—prefer scoping to the checkout step.Better isolation
Ensure proxy-specific
GH_HOST/ API overrides do not leak into steps that must align with normalgitremotes (explicit stepenv, or explicit unset/override for checkout only).Stronger long-term
For same-repository PR heads, prefer deterministic
git fetch/git checkoutof the head ref when safe, and reservegh pr checkoutfor cross-repo / fork cases where it is required.Tests / validation
Add a regression test or workflow fixture that simulates
GH_HOSTmismatch (e.g. localhost) before checkout and asserts the generated workflow or helper normalizes env or chooses a git-native path.Observability (optional but helpful)
When webhook PR metadata is partial, concise logging of same-repo vs cross-repo checkout decisions (from API-resolved metadata) helps distinguish fork/cross-repo needs, metadata ambiguity, and proxy /
GH_HOSTmismatch.Additional note (observability)
When webhook PR metadata is thin (e.g. missing head repo), checkout strategy may differ. Logging same-repo vs cross-repo decisions would help separate:
GH_HOSTmismatch (this issue)Expected outcome
Generated gh-aw workflows check out PR branches reliably in proxied / DIFC-style environments without requiring consumers to hand-patch compiled lockfiles after every compile.
Thanks for considering this — happy to help validate a fix against our setup if useful (in generic terms, without sharing private repository details).