Skip to content

ci: authenticate to ghcr.io so the validate job's pulls are not anonymous - #607

Merged
Gerrrt merged 1 commit into
mainfrom
claude/remaining-purchase-items-bim3ep
Sep 22, 2026
Merged

Gerrrt merged 1 commit into
mainfrom
claude/remaining-purchase-items-bim3ep

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Sep 22, 2026

Copy link
Copy Markdown
Owner

What changed

.github/workflows/ci.yml, two edits and nothing else:

  • permissions: gains packages: read. Reads only; nothing here writes a package.
  • The validate job gains a docker login ghcr.io step, immediately after checkout so every later step benefits.

This is option 1 of #602. Options 2 and 3 there — caching pulled images, and tuning the backoff — are deliberately not in this PR.

Why

The probe step pulls every pinned image in every stack on every pull request: about six minutes of registry traffic, four of them for stacks/sensitive alone. Twice that volume tripped ghcr.io's per-minute limit on diffs that were Markdown only, and on 2026-09-21 check_compose_health.py's PULL_RETRY_PAUSES fired all three of its pauses — 5 s, 20 s, 60 s — and the fourth attempt failed anyway. More backoff is not the lever. Fewer anonymous requests is.

ghcr.io rate-limits by the identity asking, and an anonymous pull from a GitHub runner is identified by an egress IP shared with everything else running on it. GITHUB_TOKEN is scoped to this run and to reads, which is all a pull needs.

A plain docker login, not an action — so this adds no third-party dependency to pin, which matters in a repository whose check_image_pins.py exists to keep pins in one place.

What it deliberately does not do

It cannot fail the job. A login that does not happen — a fork's restricted token, a registry outage — leaves the pulls anonymous, which is exactly where they already were, and every check below still fails loudly on an image it cannot fetch. Hard-failing here would add a second way for CI to go red for a reason no diff can cause, which is the thing #602 is about. The failure path emits two ::warning:: lines rather than passing silently.

Nothing is weakened. --probe stays unconditional; it still fails rather than skips when there is no daemon, and it still pulls and execs inside every pinned image. That property is the one #602 explicitly protects, quoting this file: "scripts/validate.sh may honestly skip it on a host without docker; CI may not." A docs/** path filter would have violated it — this does not.

Docker Hub is untouched. Separate quota, separate decision, and nothing has failed there.

Local runs are unchanged. scripts/validate.sh uses whatever credentials the operator's docker already has; authentication is environment-specific, not a check, so this is not the CI/local drift the rest of this file works to prevent.

Blast radius

One workflow file. No host, no service, no stack, no script. The change is inert unless a step pulls from ghcr.io.

  • No change to network segmentation or firewall rules
  • No new port published to a VLAN that could not already reach the service
  • No credential added outside secrets/*.sops.yaml — GITHUB_TOKEN is minted per run by Actions and is not stored anywhere

The token is passed through env: and piped via --password-stdin, so it is not in a command line or an interpolated run: string. github.actor is likewise read from env: rather than interpolated into the script.

Verification

Run locally after installing the linters this container was missing, because this diff is YAML and the last several were not — "no YAML changed" was doing the work in earlier PRs and cannot here:

  • ./scripts/lint.sh → yamllint PASS, markdownlint-cli2 PASS, shellcheck PASS, actionlint PASS, delegation check PASS. Only editorconfig-checker skipped (needs a docker daemon); its three rules for this file — final newline, no trailing whitespace, spaces not tabs — were checked by hand against the diff and are clean.
  • actionlint with shellcheck on PATH is the one that matters here: it lints the run: block's shell and flags ${{ }} interpolation into scripts. Clean.
  • python3 scripts/check_image_pins.py → image pins OK — 42 docker run/pull/create invocation(s) across 14 file(s). docker login is not a run/pull/create, so it is correctly outside that parser's scope.
  • python3 scripts/check_docs.py → docs OK — 10 assertions.
  • The workflow parses, and permissions reads {'contents': 'read', 'packages': 'read'}.

What cannot be verified from here: that an authenticated pull actually clears the limit. That is only observable on a runner, and the honest test is the next few PRs not going red the same way. If one does, #602 stays open and option 2 — caching — is next.

What remains on #602

Its "done when" has three parts; this closes one. Still open: image caching between runs, and a fixture covering the retry path so the toomanyrequests handling cannot regress silently.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Wfbt4PLuuFhJY97LGjrZ89


Generated by Claude Code

…mous

The probe step pulls every pinned image in every stack on every pull
request — about six minutes of registry traffic, four of them for
stacks/sensitive alone. Twice that volume tripped ghcr.io's rate limit on
diffs that were Markdown only, and on 2026-09-21 the retry in
check_compose_health.py fired all three of its pauses and the fourth
attempt still failed. More backoff is not the lever; fewer anonymous
requests is.

ghcr.io limits by the identity asking, and an anonymous pull from a runner
is identified by an egress IP shared with everything else on it.
GITHUB_TOKEN is scoped to the run and, with the packages: read added here,
to reads — which is all a pull needs. A plain docker login rather than an
action, so nothing new has to be pinned.

The step cannot fail the job. A login that does not happen — a fork's
restricted token, a registry outage — leaves the pulls anonymous, which is
where they already were, and every check below still fails loudly on an
image it cannot fetch. Hard-failing would add a second way for CI to go red
for a reason no diff can cause, which is the thing being fixed.

Nothing weakens: --probe stays unconditional, still fails rather than skips
without a daemon, and still pulls and execs inside every image. Docker Hub
is untouched — separate quota, separate decision, nothing has failed there.

Refs #602

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wfbt4PLuuFhJY97LGjrZ89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants