Add GitHub Enterprise Cloud host support - #605
Open
mightyguava wants to merge 1 commit into
Open
Conversation
mightyguava
force-pushed
the
yunchi/ghe
branch
from
August 13, 2026 17:23
6a97ff1 to
1e3e065
Compare
Co-authored-by: Codex <codex-noreply@coinbase.com>
mightyguava
force-pushed
the
yunchi/ghe
branch
from
August 13, 2026 18:11
1e3e065 to
7307995
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add host-aware GitHub Enterprise support for private release downloads and git source rewrites.
This specifically adds support for GitHub Enterprise Cloud with data residency, where the web host is a
subdomain.ghe.comhost and the API host isapi.subdomain.ghe.com. The implementation should also work for GitHub Enterprise more generally by allowing additional enterprise hosts to be configured ingithub-token-auth.Changes
1. Config now supports multiple GitHub auth blocks
github-token-authis now repeatable and host-aware. For GitHub Enterprise Cloud with data residency (*.ghe.com), this block is optional for release downloads because Hermit recognizes those hosts by default and will try to fetch credentials from the GitHub CLI withgh auth token -h <host>.The block is still available when you want to override the token environment variable, or when using a self-hosted GitHub Enterprise domain that is not
github.comor*.ghe.com:The default host remains
github.com, preserving existing behavior for current configs.2. Added host-aware GitHub client configuration
Added
github.HostConfigandgithub.NewWithHosts()so a single client can know about multiple GitHub-compatible hosts and their tokens.The REST API base URL is always derived as:
Only the existing REST v3 endpoint paths are supported. The previous configurable API URL field has been removed.
3. Added host-specific GitHub API methods
Added host-aware variants for repo and release lookups:
RepoForHost()ReleaseForHost()LatestReleaseForHost()ReleasesForHost()The legacy methods still exist and route through the client default host for backwards compatibility. These could probably be removed if there are no external usages of these methods; there are very few call sites inside the Hermit repo.
4. Token injection is now scoped by host
Authentication transport now maps tokens to each configured web host and API host. A GHE token for
mycompany.ghe.comis only sent tomycompany.ghe.comandapi.mycompany.ghe.com, not togithub.comorapi.github.com.For non-
github.comhosts, if a token is not configured throughtoken-env, Hermit uses:If the
ghCLI is unavailable or token lookup fails, Hermit returns an explicit error asking the user to authenticate that host withgh.5. Private release source selection is now host-aware and non-recursive
Private release source selection now uses a single aggregate selector rather than wrapping one selector per host. It recognizes GitHub-style release URLs on:
github.com*.ghe.comhosts by defaultgithub-token-authWhen a URL matches, Hermit uses the host-specific GitHub releases API to find and download the asset instead of following browser login/SSO redirects.
6. Added defensive checks for release asset URLs
Release asset downloads and ETag checks now validate the returned asset URL against the configured host/API host. For a non-
github.comhost, Hermit also refuses redirects togithub.comorapi.github.com.This might be unnecessary in normal GitHub Enterprise behavior, but seemed harmless and prevents a GHE source from accidentally using GitHub.com URLs if an unexpected asset URL or redirect is returned. Presigned release asset redirects to object storage hosts like
objects-origin.<host>are allowed and are not treated as GitHub hosts for auth.7. Git source URL rewriting supports GHE HTTPS URLs
Added
AuthenticatedURLRewriterForHost()so HTTPS git sources on configured enterprise hosts can be rewritten with the correct token while preserving the original host:becomes:
SSH URLs are still passed through unchanged.
8. App wiring builds one GitHub client from all configured hosts
Hermit now reads all configured
github-token-authblocks, resolves each configured env token, and installs one aggregate source selector plus host-specific source rewriters.9. Manifest inference carries the GitHub host through repo lookup
Manifest inference now uses
ProjectForURLWithHost()andRepoForHost()so GHE artifact URLs do not accidentally callapi.github.comfor repo metadata.For non-
github.comhosts, inference does not emitgithub-release = "owner/repo"because autoversion has not been updated to support GitHub Enterprise yet.Notes
github-releaseautoversion still uses the legacy GitHub.com-oriented interface.subdomain.ghe.com) but should work for GitHub Enterprise in general.*.ghe.com),github-token-authis optional for release downloads unless you want to overridetoken-env; self-hosted GitHub Enterprise domains still need a configured block.gh auth status --json hostsis not used for host discovery; Hermit recognizesgithub.com/*.ghe.comby default and uses configured hosts for other enterprise domains.Test Plan
GOROOT= GOCACHE=$PWD/.tmp9/gocache GOMODCACHE=$PWD/.tmp9/gomodcache go test ./...git diff --check