Skip to content

build/bake: BuildKit secrets support#248

Open
crazy-max wants to merge 1 commit into
docker:mainfrom
crazy-max:buildkit-secrets
Open

build/bake: BuildKit secrets support#248
crazy-max wants to merge 1 commit into
docker:mainfrom
crazy-max:buildkit-secrets

Conversation

@crazy-max

@crazy-max crazy-max commented Jul 7, 2026

Copy link
Copy Markdown
Member

fixes #40
closes #239

This adds BuildKit secret support to the build and bake reusable workflows through a shared build-secrets workflow secret.

The new build-secrets secret accepts a YAML object that maps BuildKit secret IDs to secret values. The build workflow parses that YAML and forwards each entry to docker/build-push-action through secret-envs. The bake workflow uses the same contract and appends matching *.secrets+=id=...,env=... overrides for docker/bake-action.

A caller can pass a literal multiline secret with YAML block syntax.

secrets:
  build-secrets: |
    npmrc: |
      //registry.npmjs.org/:_authToken=token
      always-auth=true

A caller can also pass GitHub secrets through toJSON(...) so multiline values and YAML-sensitive characters are preserved.

secrets:
  build-secrets: |
    npmrc: ${{ toJSON(secrets.NPMRC) }}
    aws_credentials: ${{ toJSON(secrets.AWS_CREDENTIALS) }}

Reusable workflows cannot accept arbitrary dynamic secret names, so this keeps the public contract stable while still allowing callers to provide any BuildKit secret ID they need. File-based secrets are intentionally not supported because these workflows build from Git context and do not checkout the caller repository, so caller workspace paths are not available in the build job.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max crazy-max marked this pull request as ready for review July 7, 2026 11:02
@crazy-max crazy-max requested a review from a team as a code owner July 7, 2026 11:02
@crazy-max crazy-max requested a review from tonistiigi July 7, 2026 11:02
@crazy-max crazy-max mentioned this pull request Jul 7, 2026
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.

Secrets support

1 participant