hashicorp / hashicorp/setup-terraform
Add support for GITHUB_TOKEN
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 288
- Avg merge
- 23h 21m
- Merged PRs (30d)
- 3
Description
I still think this should be an unresolved bug against the `setup-terraform` GitHub action. While I agree that some of the comments in the original thread do provide a solution for the problem, they're ultimately janky at best, and don't really fit a best practices approach, given that you now have to create, essentially, an "admin" user, and proliferate SSH keys.
The GH action is supplied to make using terraform within GitHub actions easier, but doesn't automatically bootstrap the vendor supplied method for authenticating (`GITHUB_TOKEN`)? Every other GH action makes use of this concept without forcing the problem onto its users. I can understand the terraform project itself staying away from this behavior. But not the GH action.
In any case, after running into this issue myself and hating the idea of scripting my own credential provider with bogus shell scripts or being forced to switch to SSH just for this, I stumbled upon this suggestion:
https://wahlnetwork.com/2020/08/11/using-private-git-repositories-as-terraform-modules/
Basically, you can inject your GITHUB_TOKEN into your git configuration with the following:
`git config --global url."https://oauth2:${{ secrets.GITHUB_TOKEN }}@github.com".insteadOf https://github.com`
Works like a charm.
_Originally posted by @doug-papenthien-by in https://github.com/hashicorp/setup-terraform/issues/33#issuecomment-714837963_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.