feat: use GitHub CLI if available to auth instead of GITHUB_TOKEN#694
Open
lukas-preply wants to merge 3 commits intocallstackincubator:mainfrom
Open
feat: use GitHub CLI if available to auth instead of GITHUB_TOKEN#694lukas-preply wants to merge 3 commits intocallstackincubator:mainfrom
lukas-preply wants to merge 3 commits intocallstackincubator:mainfrom
Conversation
Co-authored-by: lukas-preply <177529352+lukas-preply@users.noreply.github.com>
feat: add GitHub CLI as fallback for GITHUB_TOKEN
|
@lukas-preply is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
thymikee
reviewed
Mar 25, 2026
| } | ||
| let token = getGitHubToken(); | ||
| let token = | ||
| getGitHubToken() ?? process.env['GITHUB_TOKEN'] ?? (await getGitHubCLIToken()); |
Contributor
There was a problem hiding this comment.
do we need to include the process.env['GITHUB_TOKEN'] here?
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.
Motivation
Screenshot
GITHUB_TOKENbeing set.Summary
This pull request introduces a fallback mechanism for GitHub authentication in the cache provider, allowing the use of the GitHub CLI (
gh auth token) when no explicit token or environment variable is available. It also adds comprehensive tests to verify the new logic. The most important changes are grouped below:Authentication fallback enhancements:
getGitHubCLITokenfunction inconfig.tsto retrieve a GitHub token from the GitHub CLI, falling back when no explicit token orGITHUB_TOKENenvironment variable is found.detectGitHubRepoDetailsto prioritize explicit token, then environment variable, then GitHub CLI, improving user experience and flexibility.GitHubBuildCacheconstructor andgetRepoDetailsmethod to defer token resolution and support asynchronous fallback to the GitHub CLI, throwing a clear error if no token is available.Testing improvements:
ghCliFallback.test.tsto verify all fallback scenarios, including explicit token, environment variable, GitHub CLI, and error handling when no token is available.Code organization:
providerGitHub.tsto includegetGitHubCLITokenfor use in the cache provider logic.