You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1bd35d3
Browse filesBrowse the repository at this point in the historyBrowse files
The unsealed sibling of cargo-fetch's git-token input, for jobs that run plain cargo build or git clone on the runner.
Exports the url.insteadOf rewrite as GIT_CONFIG_* environment entries — they die with the job, so nothing lands in a gitconfig file on self-hosted runners — and sets CARGO_NET_GIT_FETCH_WITH_CLI so cargo's fetches honor it.
Invocations append behind each other.
The defaults speak GitHub, but any authenticated https git host works: host takes an optional port, username carries the host's convention (oauth2 for GitLab, x-token-auth for Bitbucket), and path scopes the rewrite to a namespace, nested groups included.
Host, username and path are each validated against their charset before they can reach a gitconfig key; minting stays with the caller.
Selftest covers the GitHub defaults, a self-hosted GitLab group with port and username, the append behavior, and the invalid-path and invalid-host refusals.
Documented in the README action list and docs/private-git-dependencies.md.
Copy file name to clipboardExpand all lines: README.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -322,6 +322,20 @@ See [the action's README](.github/actions/cargo-install/README.md) for the secur
322
322
Run a `cargo-install`'d tool from the shared cache, sealed and network-isolated by default.
323
323
See [the action's README](.github/actions/cargo-use/README.md).
324
324
325
+
### `route-git-token`
326
+
327
+
Route git fetches ON THE RUNNER through a short-lived token: an `url.insteadOf` rewrite exported as `GIT_CONFIG_*` environment entries (they die with the job — nothing lands in a gitconfig file, which matters on self-hosted runners) plus `CARGO_NET_GIT_FETCH_WITH_CLI` so cargo's fetches honor it.
328
+
The unsealed sibling of `cargo-fetch`'s `git-token` input, for jobs that run plain `cargo build` or `git clone` outside the container.
329
+
The defaults speak GitHub, but any authenticated https git host works: `host:`and `username:` carry the host's convention (GitLab OAuth: `oauth2`; Bitbucket: `x-token-auth`), and `path:` optionally scopes the rewrite to a namespace — nested groups included.
330
+
Invocations append, so two tokens for two hosts or namespaces coexist.
A release gate split into **network-with-no-code** then **code-with-no-network**.
@@ -423,6 +437,7 @@ The token must carry `contents: read` on every private dependency repository.
423
437
The default `GITHUB_TOKEN` only grants access to the workflow's own repository, so a cross-repository dependency needs a fine-grained PAT or a GitHub App installation token, stored as a secret.
424
438
See [docs/private-git-dependencies.md](docs/private-git-dependencies.md) for the GitHub App setup and an in-workflow minting example.
425
439
The sealed `lint-and-test-docker` passes run `--offline` against the cache `cargo-fetch` populated, so they need no token.
440
+
Jobs that build on the runner instead of in the container route the same token with [`route-git-token`](#route-git-token).
The action is not GitHub-bound: `host:`(with an optional port) and `username:` route any authenticated https git host — a self-hosted GitLab takes `host: gitlab.example.com` with `username: oauth2` and a nested `path: group/sub-group`.
74
+
Only the minting is ecosystem-specific, and that stays with the caller.
75
+
76
+
It exports the `url.insteadOf` rewrite as `GIT_CONFIG_*` environment entries (they die with the job — nothing lands in a gitconfig file, which matters on self-hosted runners) and sets `CARGO_NET_GIT_FETCH_WITH_CLI` so cargo's fetches honor it. The rewrite is a transport detail: scope the TOKEN, as above — a rewrite for a repository the token cannot read fails exactly like no rewrite at all.
77
+
61
78
## Fine-grained PAT (simpler alternative)
62
79
63
80
Create a fine-grained PAT with **Contents: Read** on each private dependency repository, store it as a secret, and pass it directly:
0 commit comments