Repository navigation
minimal-crates: accept a GIT_TOKEN secret for private git dependencies - #13
Merged
Merged
Conversation
Callers that patch in a private GitHub repository cannot run this workflow: it takes no secrets, and the caller's env does not reach a called workflow, so cargo fetches the repository without credentials. Add an optional GIT_TOKEN secret and a git-token-repo input. With both set, git rewrites https://github.com/<git-token-repo> to carry the token and cargo fetches with the git CLI. Without them, nothing changes. Document the pair in the README as the convention for every shared workflow that runs cargo.
Drop the git-token-repo input. With GIT_TOKEN, every job rewrites https://github.com/ to carry the token. Public fetches and checkout's own auth header keep working with the token in the URL.
With the token in the URL, git hands it to the credential helpers after each successful fetch. On macOS, Homebrew git's osxkeychain helper then blocks during actions/checkout, which runs with a temporary HOME, and the job hangs. Reset credential.helper to empty.
flub
approved these changes
Nov 26, 2026
flub
left a comment
Collaborator
There was a problem hiding this comment.
to me there's one nonsensical explanation, but it seems to work so whatever.
| env: | ||
| # Every job fetches github.com git dependencies with GIT_TOKEN, if given. | ||
| # The empty credential.helper stops git from storing the token after a | ||
| # fetch: macOS osxkeychain blocks during actions/checkout. |
Collaborator
There was a problem hiding this comment.
I don't understand what this line is saying, same in the PR description.
Contributor
Author
There was a problem hiding this comment.
Mac os was bugging out because it has its os keychain thing which intervenes before things can proceed and unless set will just hang for input. This just works around it.
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.
Description
A caller that patches in a private GitHub repository cannot run
minimal-crates.yaml. The workflow takes no secrets, and the caller'senvdoes not reach a called workflow, so cargo fetches the repository without credentials and fails:This PR:
GIT_TOKENsecret tominimal-crates.yaml.env, so every job uses it. WithGIT_TOKEN, git rewriteshttps://github.com/to carry the token (GIT_CONFIG_*env vars). Cargo fetches with the git CLI so that the rewrite applies.credential.helperto empty. With credentials in the URL, git gives them to the credential helpers to store after each successful fetch. On macOS, Homebrew git'sosxkeychainhelper blocks duringactions/checkout, which runs with a temporaryHOME, and the job hangs.GIT_TOKEN,GIT_CONFIG_COUNTis0and no URL changes. The only change for current callers is that cargo fetches git dependencies with the git CLI.GIT_TOKEN. A new shared workflow, such ascargo-deny.yamlin Add cargo-deny checks #12, must take it too.Usage:
Testing
GIT_CONFIG_*values, with global config off and a system config whosecredential.helperblocks (like Homebrew'sosxkeychain):actions/checkoutcase (itsextraheaderplus the token in the URL) each fetch in about 1 s. Git does not call the helper.credential.helperreset, git calls the helper'sstoreafter each fetch and hangs. This matches the macOS hang in CI.zizmor --offline .: no findings.actionlint: same findings as onmain(runner labels,$/action refs, the Windowscargo checkstep). None comes from this change.credential.helperreset, Ubuntu and Windows passed and macOS hung inactions/checkout. At 507db95, Ubuntu, macOS and Windows pass.Release
After merge: tag
v2.0.1and movev2.v2does not have #11 yet, so this release also ships the Windows target dir fix.