feat(docker-build): add secret-build-args for secret-valued build args#2
feat(docker-build): add secret-build-args for secret-valued build args#2samuelho-dev wants to merge 1 commit into
Conversation
GitHub strips secret values from job outputs, so a caller that resolves environment-scoped secrets in one job and hands them to this reusable workflow's build-args input via `needs.x.outputs.*` gets EMPTY build-args — silently baking undefined into the image (e.g. NEXT_PUBLIC_* inlined as undefined by next build, crashing the app at runtime env validation). Add a `secret-build-args` secret input, merged with the plain build-args inside the build job (where secrets resolve). Read from an env var so values aren't echoed; step outputs keep real values within a job (only cross-job outputs are stripped). build-args bake into image layers, so this is for public-anyway values (NEXT_PUBLIC_*), documented in the input description. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe workflow now supports secret build arguments via a new ChangesSecret Docker Build Arguments
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/docker-build-push.yml (1)
82-91: ⚡ Quick winDocument
secret-build-argsindocs/USAGE.md.This adds a new caller-facing workflow contract, but the current usage table in
docs/USAGE.md:63-79still only listsbuild-args. Please addsecret-build-argsthere as well, including the “public values only” caveat, so consumers don’t miss the new path or treat it like a safe channel for real secrets.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/docker-build-push.yml around lines 82 - 91, Update docs/USAGE.md to add the new workflow input "secret-build-args" alongside "build-args" in the usage table (the section currently listing build-args); document that it accepts KEY=VALUE pairs (one per line), that values are resolved inside the job, and include the explicit caveat that build args bake into image layers and therefore should only be used for public values (e.g., NEXT_PUBLIC_*) and never for true secrets; reference the workflow input name "secret-build-args" and keep the phrasing consistent with the existing "build-args" entry.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.github/workflows/docker-build-push.yml:
- Around line 82-91: Update docs/USAGE.md to add the new workflow input
"secret-build-args" alongside "build-args" in the usage table (the section
currently listing build-args); document that it accepts KEY=VALUE pairs (one per
line), that values are resolved inside the job, and include the explicit caveat
that build args bake into image layers and therefore should only be used for
public values (e.g., NEXT_PUBLIC_*) and never for true secrets; reference the
workflow input name "secret-build-args" and keep the phrasing consistent with
the existing "build-args" entry.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0e6e49aa-d013-4ecf-9799-29e185899a4a
📒 Files selected for processing (1)
.github/workflows/docker-build-push.yml
|
Closing — research showed the correct fix is runtime injection of NEXT_PUBLIC_* (build once, deploy anywhere), which eliminates the build-arg path entirely rather than working around GitHub's secret-output stripping. The secret-build-args input would just prolong build-time inlining. Superseded by the runtime-injection refactor in creativetoolkits. |
Why
GitHub Actions strips secret values from job outputs (security). A caller that resolves environment-scoped secrets in one job and passes them to this reusable workflow's
build-argsvianeeds.resolve-env.outputs.*therefore gets empty build-args — silently bakingundefinedinto the image. Concretely: creativetoolkits'next buildinlinedNEXT_PUBLIC_*as undefined, crashing nextjs + payload-cms at runtime env validation.Fix
New
secret-build-argssecret input, merged with plainbuild-argsinside the build job (where secrets resolve — no cross-job output stripping). Values are read from an env var so they're not echoed; GitHub masks them in logs.docker/build-push-actionde-dupes by key, secret args appended last so they win.build-args bake into image layers (
docker history), so this is documented as for public-anyway values (NEXT_PUBLIC_*), never true secrets.Consumer
creativetoolkits
cd.yamlbuild-frontend will pass NEXT_PUBLIC_* viasecrets.secret-build-argsinstead of the brokenresolve-env.outputs.*handoff (separate PR).🤖 Generated with Claude Code
Summary by CodeRabbit