Include a new gh_token secret in builds #57
Merged
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.
This should allow the following for
go get
in a Dockerfile:RUN --mount=type=secret,id=gh_token
git config --global "url.https://github-actions:$(cat /run/secrets/gh_token)@github.com/.insteadOf" https://github.com/
** NOTE WELL **
You MUST use multi-stage builds where stages containing this git config aren't included in the image that's pushed to any registries, otherwise the token will be embedded in the image! Build in one stage, copy the build executable from that stage to a release stage, and then push the release stage to the registry.
(The github token that's presented to the builds does expire after 24h, so it's not the end of the world, but it's still important)
This example allows using ssh-agent forwarding when building in a local docker, but uses gh_token in CI: