feat: add gitdan-crates-access, a deploy-key action for the private crates repo
The job token cannot read daniel/gitdan-crates, so CI authenticates with a read-only deploy key. The action writes it 0600 outside the workspace, pins the forge's host key (RSA, the only type offered, confirmed against the trusted known_hosts record and a fresh keyscan), exports GIT_SSH_COMMAND, proves access with ls-remote, and fails on a Cargo.lock with two commits of the crates repo. The selftest is wired into selftest.sh. Existing actions and scripts are untouched. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MfBCVNDv3y5gm2djeZSAk4
This commit is contained in:
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
# Fails when a Cargo.lock lists more than one commit of the gitdan-crates
|
||||
# git source: two commits mean two copies of every shared type.
|
||||
#
|
||||
# crates-lock-check.sh <path-to-Cargo.lock>
|
||||
#
|
||||
# Several packages from the one source share a commit, so what counts is
|
||||
# distinct commits, not entries. The query string (`?branch=main`, `?rev=...`)
|
||||
# is ignored, and so is the URL's spelling (scheme, port, `.git`): two copies
|
||||
# of the repo are two copies whichever way they were named. No entry passes.
|
||||
set -euo pipefail
|
||||
|
||||
[ $# -eq 1 ] || { echo "::error::crates-lock-check: expected <path-to-Cargo.lock>" >&2; exit 1; }
|
||||
lock="$1"
|
||||
[ -f "$lock" ] || {
|
||||
echo "::error::gitdan-crates-access: lockfile '$lock' not found; set the action's 'lockfile' input to its path, or to an empty string to skip the check" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# source = "git+<url>[?query]#<sha>"
|
||||
shas=$(sed -nE 's#^source = "git\+[^"?\#]*daniel/gitdan-crates(\.git)?(\?[^"\#]*)?\#([^"]*)"$#\3#p' "$lock" | sort -u)
|
||||
count=$(grep -c . <<<"$shas" || true)
|
||||
|
||||
if [ "$count" -gt 1 ]; then
|
||||
echo "::error::$lock locks $count different commits of gitdan-crates; every consumer must resolve one, or shared types are duplicated. Run: cargo update -p <crate> --precise <sha>, or cargo update, to unify them:" >&2
|
||||
while read -r s; do echo " $s" >&2; done <<<"$shas"
|
||||
exit 1
|
||||
fi
|
||||
echo "gitdan-crates lock check: ${count} commit(s) of gitdan-crates in $lock"
|
||||
Reference in New Issue
Block a user