-
Notifications
You must be signed in to change notification settings - Fork 698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] Pick up token from gh auth login
CLI
#1854
Conversation
This PR adds the use of token persisted by GitHub CLI (https://cli.github.com) via running the `gh auth token --hostname $base_url` command and using the token from that command.
cc @kfcampbell @nickfloyd this one is without introducing any new module dependencies. |
@kfcampbell docs updated |
@kfcampbell Following up |
@kfcampbell @nickfloyd when can we get this released? 😀 |
My team is also eager to see this PR merged. thank you for your work, @nfx. |
I'll be taking a look at this today, if everything checks out, I'll get it merged and released as well. Thanks for the patience and contributions here! ❤️ |
gh auth login
CLIgh auth login
CLI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contributions! ❤️
This PR is a follow-up to integrations#1854 GitHub CLI uses different base URLs in `~/.config/gh/hosts.yml`, so when we're using the standard base path of this provider, it doesn't align with how `gh` CLI stores the credentials. The following doesn't work: ``` $ gh auth token --hostname api.github.com > no oauth token ``` ... but the following does work correctly ``` $ gh auth token --hostname github.com > gh..<valid token> ``` attempted a workaround with ``` provider "github" { owner = "..." base_url = "github.com" } ``` But it didn't work as expected.
This PR is a follow-up to integrations#1854 GitHub CLI uses different base URLs in `~/.config/gh/hosts.yml`, so when we're using the standard base path of this provider, it doesn't align with how `gh` CLI stores the credentials. The following doesn't work: ``` $ gh auth token --hostname api.github.com > no oauth token ``` ... but the following does work correctly ``` $ gh auth token --hostname github.com > gh..<valid token> ``` attempted a workaround with ``` provider "github" { owner = "..." base_url = "github.com" } ``` But it didn't work as expected.
This PR adds the use of token persisted by GitHub CLI (https://cli.github.com) via running the
gh auth token --hostname $base_url
command and using the token from that command.Resolves #1822
Before the change?
gh
-authenticated machines had to pass the token via env variable:gh auth login
GITHUB_TOKEN=$(gh auth token) terraform apply
After the change?
gh
-authenticated machines do not have to pass the token via env variable:gh auth login
terraform apply
Does this introduce a breaking change?
Please see our docs on breaking changes to help!