Skip to content

Commit 52b7d9f

Browse files
committed
distribute: opt to set meta annotations and labels
Signed-off-by: CrazyMax <[email protected]>
1 parent fc79706 commit 52b7d9f

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

.github/workflows/reusable-distribute.yml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Reusable workflow to distribute multi-platform builds efficiently
2+
# https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
23
name: reusable-distribute
34

45
on:
@@ -19,6 +20,16 @@ on:
1920
description: "Push image to registry"
2021
required: false
2122
default: false
23+
set-meta-annotations:
24+
type: boolean
25+
description: "Set metadata-action annotations"
26+
required: false
27+
default: false
28+
set-meta-labels:
29+
type: boolean
30+
description: "Set metadata-action labels"
31+
required: false
32+
default: false
2233
setup-qemu:
2334
type: boolean
2435
description: "Install QEMU static binaries"
@@ -358,6 +369,30 @@ jobs:
358369
-
359370
name: Set up Docker Buildx
360371
uses: docker/setup-buildx-action@v3
372+
-
373+
name: Prepare metadata bake files
374+
id: meta-bake-files
375+
uses: actions/github-script@v7
376+
env:
377+
INPUT_SET-META-ANNOTATIONS: ${{ inputs.set-meta-annotations }}
378+
INPUT_SET-META-LABELS: ${{ inputs.set-meta-labels }}
379+
with:
380+
result-encoding: string
381+
script: |
382+
const os = require('os');
383+
384+
const inpSetMetaAnnotations = core.getBooleanInput('set-meta-annotations');
385+
const inpSetMetaLabels = core.getBooleanInput('set-meta-labels');
386+
let bakeFiles = [`cwd://${{ steps.meta.outputs.bake-file-tags }}`];
387+
if (inpSetMetaAnnotations) {
388+
bakeFiles.push(`cwd://${{ steps.meta.outputs.bake-file-annotations }}`);
389+
}
390+
if (inpSetMetaLabels) {
391+
bakeFiles.push(`cwd://${{ steps.meta.outputs.bake-file-labels }}`);
392+
}
393+
394+
core.info(JSON.stringify(bakeFiles, null, 2));
395+
return bakeFiles.join(os.EOL);
361396
-
362397
name: Build
363398
id: bake
@@ -366,7 +401,7 @@ jobs:
366401
source: ${{ inputs.bake-source }}
367402
files: |
368403
${{ inputs.bake-files }}
369-
cwd://${{ steps.meta.outputs.bake-file }}
404+
${{ steps.meta-bake-files.outputs.result }}
370405
targets: ${{ inputs.target }}
371406
allow: ${{ inputs.bake-allow }}
372407
no-cache: ${{ inputs.bake-no-cache }}
@@ -406,8 +441,6 @@ jobs:
406441
images: ${{ inputs.meta-image }}
407442
tags: ${{ inputs.meta-tags }}
408443
flavor: ${{ inputs.meta-flavor }}
409-
labels: ${{ inputs.meta-labels }}
410-
annotations: ${{ inputs.meta-annotations }}
411444
bake-target: ${{ inputs.meta-bake-target }}
412445
-
413446
name: Login to registry

0 commit comments

Comments
 (0)