Skip to content

minimal-crates: accept a GIT_TOKEN secret for private git dependencies - #13

Merged
Arqu merged 3 commits into
mainfrom
arqu/min-crates-git-token
Nov 26, 2026
Merged

Arqu merged 3 commits into
mainfrom
arqu/min-crates-git-token

Conversation

@Arqu

@Arqu Arqu commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

A caller that patches in a private GitHub repository cannot run minimal-crates.yaml. The workflow takes no secrets, and the caller's env does not reach a called workflow, so cargo fetches the repository without credentials and fails:

fatal: could not read Username for 'https://github.com': No such file or directory
error: failed to load source for dependency `noq`

This PR:

  • Adds an optional GIT_TOKEN secret to minimal-crates.yaml.
  • Sets the token in the workflow-level env, so every job uses it. With GIT_TOKEN, git rewrites https://github.com/ to carry the token (GIT_CONFIG_* env vars). Cargo fetches with the git CLI so that the rewrite applies.
  • Resets credential.helper to empty. With credentials in the URL, git gives them to the credential helpers to store after each successful fetch. On macOS, Homebrew git's osxkeychain helper blocks during actions/checkout, which runs with a temporary HOME, and the job hangs.
  • Without GIT_TOKEN, GIT_CONFIG_COUNT is 0 and no URL changes. The only change for current callers is that cargo fetches git dependencies with the git CLI.
  • Documents in the README that every shared workflow takes GIT_TOKEN. A new shared workflow, such as cargo-deny.yaml in Add cargo-deny checks #12, must take it too.

Usage:

  min-crates:
    uses: "n0-computer/workflows/.github/workflows/minimal-crates.yaml@v2"
    secrets:
      GIT_TOKEN: ${{ secrets.MY_PRIVATE_REPO_TOKEN }}

Testing

  • With git and the same GIT_CONFIG_* values, with global config off and a system config whose credential.helper blocks (like Homebrew's osxkeychain):
    • A private repository, a public repository and the actions/checkout case (its extraheader plus the token in the URL) each fetch in about 1 s. Git does not call the helper.
    • Without the credential.helper reset, git calls the helper's store after each fetch and hangs. This matches the macOS hang in CI.
  • zizmor --offline .: no findings.
  • actionlint: same findings as on main (runner labels, $/ action refs, the Windows cargo check step). None comes from this change.
  • A private caller with a private git dependency ran this workflow in CI. Before the credential.helper reset, Ubuntu and Windows passed and macOS hung in actions/checkout. At 507db95, Ubuntu, macOS and Windows pass.

Release

After merge: tag v2.0.1 and move v2. v2 does not have #11 yet, so this release also ships the Windows target dir fix.

Arqu added 2 commits November 26, 2026 08:51
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.
@Arqu Arqu changed the title minimal-crates: accept a token for a private git dependency minimal-crates: accept a GIT_TOKEN secret for private git dependencies Nov 26, 2026
@Arqu
Arqu requested a review from flub November 26, 2026 08:12
@n0bot n0bot Bot added this to iroh Nov 26, 2026
@github-project-automation github-project-automation Bot moved this to 🚑 Needs Triage in iroh Nov 26, 2026
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 flub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this line is saying, same in the PR description.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Arqu
Arqu merged commit e498338 into main Nov 26, 2026
2 checks passed
@Arqu
Arqu deleted the arqu/min-crates-git-token branch November 26, 2026 09:35
@github-project-automation github-project-automation Bot moved this from 🚑 Needs Triage to ✅ Done in iroh Nov 26, 2026
@Arqu
Arqu restored the arqu/min-crates-git-token branch November 26, 2026 09:36
@Arqu
Arqu deleted the arqu/min-crates-git-token branch November 26, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants