Skip to content

feat!: add the bake.yml reusable workflow - #83

Draft
Ilyes512 wants to merge 4 commits into
4.0/specs-hclfrom
4.0/bake-workflow
Draft

Ilyes512 wants to merge 4 commits into
4.0/specs-hclfrom
4.0/bake-workflow

Conversation

@Ilyes512

@Ilyes512 Ilyes512 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

One call builds and publishes every target in a consumer's bake files: plan → build (one job per platform) → publish → status (Image).

  • plan works out VERSION, push and the other bake variables once, runs bake --print and freezes the result as an artifact. Every platform and the publish job therefore see identical tags and labels, created included. It warns when the consumer's specs.hcl differs from this version's (via SPECS_HCL_SHA256). It also reads the repository's name, description and SPDX license from the GitHub API, as the fallbacks for the title, description and licenses labels.

  • build builds all targets for its platform in one docker/bake-action run and pushes by digest. Cache scope is per image, target and platform. Default attestations are off, and attest in HCL opts in.

  • publish runs imagetools create per target, with the labels as index: and manifest-descriptor: annotations. It does no checkout.

  • push follows the event: no push for dependabot PRs (also when re-run), fork PRs, dependabot/* branches, or events the tag rules don't cover.

  • Security: build-secrets is a secret, not an input. All inputs go through env:. permissions are set per job, all actions are pinned by SHA, and checkout uses persist-credentials: false.

  • Runners: ubuntu-26.04 / ubuntu-26.04-arm by default; the runners input overrides them.

  • test-bake.yml calls the workflow with GitHub's $/ self-repository syntax. actionlint 1.7.12 knows neither that syntax nor the 26.04 labels yet (Support the new $/ self-repository uses: syntax rhysd/actionlint#711), so .github/actionlint.yaml declares the labels (added in feat: add bake/specs.hcl with the shared tag, label and annotation rules #82) and ignores only the two $/ format errors.

Tests:

  • bake/test/plan.sh runs the plan step's script, extracted with yq, for 18 GitHub contexts.
  • test-bake.yml runs the workflow on a test image (push only on a manual run with push on) and a load: true PR-style test.
  • Locally I ran the step scripts against a local registry for a full plan → build → publish. Index, descriptor, platform manifest and config labels all had the same version and created. A target with fewer platforms and an attest opt-in also worked.

Part of the 4.0.0 stack (bake variant of the plan in #80). Merge bottom to top: #82 → #83 → #84 → #85 → #86.

One call builds and publishes everything a consumer's docker-bake.hcl
defines:

- plan works out the version, the push decision and the other bake
  variables once, runs docker buildx bake --print and freezes the
  result, so every later job sees identical tags and labels (created
  included).
- build runs once per platform, building every target for that platform
  in one bake invocation, and pushes by digest.
- publish merges the digests per target with imagetools create and
  copies the labels onto the index and its descriptors.
- status reports the result as a single "Image" check.

push now follows the event instead of github.actor: no push for
dependabot pull requests (also when a person re-runs them), pull
requests from forks, dependabot branches, or events the tag rules don't
cover. Build secrets come in through one build-secrets secret. Every
input reaches the scripts through env, and every action is pinned by
commit SHA.

The plan job warns when the consumer's vendored specs.hcl differs from
bake/specs.hcl at this version, by comparing it with SPECS_HCL_SHA256;
lint.yml checks that hash, and tests the plan job's version and push
rules. test-bake.yml runs the workflow on a test image (pushing only on
a manual run), and builds, loads and runs one target the way a
consumer's pull request test would.
They reach bake as REPOSITORY_NAME, REPOSITORY_DESCRIPTION and LICENSES,
the fallbacks specs_labels uses for the title, description and licenses
labels, so a migrated image keeps the labels metadata-action gave it.
The repository is read once from the GitHub API with the token's
contents: read; an unrecognised license (NOASSERTION) is left out.

SPECS_HCL_SHA256 follows the specs.hcl change.
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.

1 participant