Add GitHub Enterprise support to the gh plugin#609
Closed
scottisloud wants to merge 1 commit into
Closed
Conversation
Use GH_ENTERPRISE_TOKEN for Enterprise Server hosts and GH_TOKEN for github.com and Enterprise Cloud, so users can authenticate to both when they have separate credentials configured. Fixes 1Password#137 Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
Closing in favor of opening a PR directly from upstream. |
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.
Overview
The GitHub shell plugin previously always provisioned
GITHUB_TOKEN, which does not work for GitHub Enterprise Server hosts. This change adds a host-aware provisioner that sets the environment variablesghexpects based on the credential's Host field:GH_TOKEN,GITHUB_TOKEN*.ghe.com):GH_TOKEN,GITHUB_TOKEN,GH_HOSTGH_ENTERPRISE_TOKEN,GITHUB_ENTERPRISE_TOKEN,GH_HOSTWhen separate 1Password items are configured for github.com and Enterprise Server, both sets of variables are provisioned so
ghcan authenticate to either host.Type of change
Related Issue(s)
How To Test
Run the GitHub plugin tests:
go test ./plugins/github/...Configure a 1Password item with a personal access token and Host set to a GitHub Enterprise Server hostname (for example
enterprise.github.com), then enable the GitHub shell plugin forgh.Run
gh auth statusorgh repo listand confirm the process receivesGH_ENTERPRISE_TOKEN,GITHUB_ENTERPRISE_TOKEN, andGH_HOSTinstead of onlyGH_TOKEN/GITHUB_TOKEN.Optionally configure a second item for github.com (with Host empty) alongside the Enterprise item and confirm both token variables are available when running
gh.Changelog
The GitHub plugin now provisions
GH_ENTERPRISE_TOKENfor GitHub Enterprise Server hosts and supports authenticating to both github.com and Enterprise when separate credentials are configured.Made with Cursor