Skip to content

ci: skip nix cache push when credentials aren't configured - #2396

Open
brainrake wants to merge 1 commit into
developfrom
marton/skip-cache-push-without-creds
Open

ci: skip nix cache push when credentials aren't configured#2396
brainrake wants to merge 1 commit into
developfrom
marton/skip-cache-push-without-creds

Conversation

@brainrake

Copy link
Copy Markdown
Collaborator

What

`push-to-cache: true` previously hard-failed the whole job if `nix-signing-key`/`role-to-assume` were empty. Now it resolves once whether push-to-cache is actually possible (requested and credentials present), and downgrades to skipping the cache push (with a `::notice::`) instead of aborting when they're not.

Why

Cache reads (`extra-substituters`) are public and unauthenticated — only the write-back needs credentials. That write is an optimization, not something that should block an otherwise-successful build. This also means any repo whose flake re-exports this one, and doesn't have (or want) its own AWS/nix-cache credentials configured, gets a fully green CI without needing to provision anything — it just never gets the cache-write optimization.

Behavior when both credentials are present: unchanged.

🤖 Generated with Claude Code

push-to-cache: true previously hard-failed the whole job if
nix-signing-key/role-to-assume were empty. Cache reads are public and
unauthenticated; only the write-back needs credentials, and it's an
optimization, not something that should block a build. Now resolves
push-to-cache once, downgrading to false (with a notice) when
requested but the credentials aren't actually present, instead of
aborting.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@brainrake
brainrake requested review from a team as code owners August 24, 2026 20:37

@mmlb mmlb 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.

lgtm

NIX_SIGNING_KEY: ${{ inputs.nix-signing-key }}
ROLE_TO_ASSUME: ${{ inputs.role-to-assume }}
VALUE=false
if [[ "${{ inputs.push-to-cache }}" == true && -n "${{ inputs.nix-signing-key }}" && -n "${{ inputs.role-to-assume }}" ]]; then

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.

fyi I went through env and the :+ok as a defense in depth in case github ships a bug and fails to mask the signing-key (previously would have thought not a chance that would happen, but these days...)

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