Skip to content

Commit 736432e

Browse files
committed
build/bake: meta-pr-head-sha input
See docker/metadata-action#206 Signed-off-by: bo0tzz <git@bo0tzz.me>
1 parent c2782c5 commit 736432e

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

.github/workflows/bake.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ on:
122122
type: string
123123
description: "List of custom annotations"
124124
required: false
125+
meta-pr-head-sha:
126+
type: boolean
127+
description: "Use the PR head SHA on pull_request events instead of GitHub's synthetic merge commit (sets DOCKER_METADATA_PR_HEAD_SHA)"
128+
required: false
129+
default: false
125130
meta-bake-target:
126131
type: string
127132
description: "Bake target name for metadata (defaults to docker-metadata-action)"
@@ -609,6 +614,8 @@ jobs:
609614
id: meta
610615
if: ${{ inputs.output == 'image' }}
611616
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
617+
env:
618+
DOCKER_METADATA_PR_HEAD_SHA: ${{ inputs.meta-pr-head-sha }}
612619
with:
613620
images: ${{ needs.prepare.outputs.metaImages }}
614621
tags: ${{ inputs.meta-tags }}
@@ -1084,6 +1091,8 @@ jobs:
10841091
id: meta
10851092
if: ${{ inputs.output == 'image' }}
10861093
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
1094+
env:
1095+
DOCKER_METADATA_PR_HEAD_SHA: ${{ inputs.meta-pr-head-sha }}
10871096
with:
10881097
images: ${{ needs.prepare.outputs.metaImages }}
10891098
tags: ${{ inputs.meta-tags }}

.github/workflows/build.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ on:
129129
type: string
130130
description: "Flavor defines a global behavior for meta-tags"
131131
required: false
132+
meta-pr-head-sha:
133+
type: boolean
134+
description: "Use the PR head SHA on pull_request events instead of GitHub's synthetic merge commit (sets DOCKER_METADATA_PR_HEAD_SHA)"
135+
required: false
136+
default: false
132137
secrets:
133138
registry-auths:
134139
description: "Raw authentication to registries, defined as YAML objects (for image output)"
@@ -502,6 +507,8 @@ jobs:
502507
id: meta
503508
if: ${{ inputs.output == 'image' }}
504509
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
510+
env:
511+
DOCKER_METADATA_PR_HEAD_SHA: ${{ inputs.meta-pr-head-sha }}
505512
with:
506513
images: ${{ needs.prepare.outputs.metaImages }}
507514
tags: ${{ inputs.meta-tags }}
@@ -940,6 +947,8 @@ jobs:
940947
id: meta
941948
if: ${{ inputs.output == 'image' }}
942949
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
950+
env:
951+
DOCKER_METADATA_PR_HEAD_SHA: ${{ inputs.meta-pr-head-sha }}
943952
with:
944953
images: ${{ needs.prepare.outputs.metaImages }}
945954
tags: ${{ inputs.meta-tags }}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ jobs:
233233
| `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) |
234234
| `meta-tags` | List | | [List of tags](https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input) as key-value pair attributes |
235235
| `meta-flavor` | List | | [Flavor](https://github.com/docker/metadata-action?tab=readme-ov-file#flavor-input) defines a global behavior for `meta-tags` |
236+
| `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)) |
236237

237238
### Secrets
238239

@@ -342,6 +343,7 @@ jobs:
342343
| `meta-labels` | List | | [List of custom labels](https://github.com/docker/metadata-action?tab=readme-ov-file#overwrite-labels-and-annotations) |
343344
| `meta-annotations` | List | | [List of custom annotations](https://github.com/docker/metadata-action?tab=readme-ov-file#overwrite-labels-and-annotations) |
344345
| `meta-flavor` | List | | [Flavor](https://github.com/docker/metadata-action?tab=readme-ov-file#flavor-input) defines a global behavior for `meta-tags` |
346+
| `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)) |
345347

346348
### Secrets
347349

0 commit comments

Comments
 (0)