From 736432e72990fce35a02adce390c1d138c92accc Mon Sep 17 00:00:00 2001 From: bo0tzz Date: Wed, 6 May 2026 20:38:22 +0200 Subject: [PATCH] build/bake: meta-pr-head-sha input See docker/metadata-action#206 Signed-off-by: bo0tzz --- .github/workflows/bake.yml | 9 +++++++++ .github/workflows/build.yml | 9 +++++++++ README.md | 2 ++ 3 files changed, 20 insertions(+) diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml index e9b3a0a..1fa6f27 100644 --- a/.github/workflows/bake.yml +++ b/.github/workflows/bake.yml @@ -122,6 +122,11 @@ on: type: string description: "List of custom annotations" required: false + meta-pr-head-sha: + type: boolean + description: "Use the PR head SHA on pull_request events instead of GitHub's synthetic merge commit (sets DOCKER_METADATA_PR_HEAD_SHA)" + required: false + default: false meta-bake-target: type: string description: "Bake target name for metadata (defaults to docker-metadata-action)" @@ -609,6 +614,8 @@ jobs: id: meta if: ${{ inputs.output == 'image' }} uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 + env: + DOCKER_METADATA_PR_HEAD_SHA: ${{ inputs.meta-pr-head-sha }} with: images: ${{ needs.prepare.outputs.metaImages }} tags: ${{ inputs.meta-tags }} @@ -1084,6 +1091,8 @@ jobs: id: meta if: ${{ inputs.output == 'image' }} uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 + env: + DOCKER_METADATA_PR_HEAD_SHA: ${{ inputs.meta-pr-head-sha }} with: images: ${{ needs.prepare.outputs.metaImages }} tags: ${{ inputs.meta-tags }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d1a46c2..22c713c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,6 +129,11 @@ on: type: string description: "Flavor defines a global behavior for meta-tags" required: false + meta-pr-head-sha: + type: boolean + description: "Use the PR head SHA on pull_request events instead of GitHub's synthetic merge commit (sets DOCKER_METADATA_PR_HEAD_SHA)" + required: false + default: false secrets: registry-auths: description: "Raw authentication to registries, defined as YAML objects (for image output)" @@ -502,6 +507,8 @@ jobs: id: meta if: ${{ inputs.output == 'image' }} uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 + env: + DOCKER_METADATA_PR_HEAD_SHA: ${{ inputs.meta-pr-head-sha }} with: images: ${{ needs.prepare.outputs.metaImages }} tags: ${{ inputs.meta-tags }} @@ -940,6 +947,8 @@ jobs: id: meta if: ${{ inputs.output == 'image' }} uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 + env: + DOCKER_METADATA_PR_HEAD_SHA: ${{ inputs.meta-pr-head-sha }} with: images: ${{ needs.prepare.outputs.metaImages }} tags: ${{ inputs.meta-tags }} diff --git a/README.md b/README.md index 3f7d031..a0eb209 100644 --- a/README.md +++ b/README.md @@ -233,6 +233,7 @@ jobs: | `meta-images` | List | | [List of images](https://github.com/docker/metadata-action?tab=readme-ov-file#images-input) to use as base name for tags (required for image output) | | `meta-tags` | List | | [List of tags](https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input) as key-value pair attributes | | `meta-flavor` | List | | [Flavor](https://github.com/docker/metadata-action?tab=readme-ov-file#flavor-input) defines a global behavior for `meta-tags` | +| `meta-pr-head-sha` | Bool | `false` | Use the PR head SHA on `pull_request` events instead of GitHub's synthetic merge commit (sets [`DOCKER_METADATA_PR_HEAD_SHA`](https://github.com/docker/metadata-action#environment-variables)) | ### Secrets @@ -342,6 +343,7 @@ jobs: | `meta-labels` | List | | [List of custom labels](https://github.com/docker/metadata-action?tab=readme-ov-file#overwrite-labels-and-annotations) | | `meta-annotations` | List | | [List of custom annotations](https://github.com/docker/metadata-action?tab=readme-ov-file#overwrite-labels-and-annotations) | | `meta-flavor` | List | | [Flavor](https://github.com/docker/metadata-action?tab=readme-ov-file#flavor-input) defines a global behavior for `meta-tags` | +| `meta-pr-head-sha` | Bool | `false` | Use the PR head SHA on `pull_request` events instead of GitHub's synthetic merge commit (sets [`DOCKER_METADATA_PR_HEAD_SHA`](https://github.com/docker/metadata-action#environment-variables)) | ### Secrets