Skip to content

Commit

Permalink
distribute: opt to set meta annotations and labels
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Feb 17, 2025
1 parent fc79706 commit 52b7d9f
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions .github/workflows/reusable-distribute.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Reusable workflow to distribute multi-platform builds efficiently
# https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
name: reusable-distribute

on:
Expand All @@ -19,6 +20,16 @@ on:
description: "Push image to registry"
required: false
default: false
set-meta-annotations:
type: boolean
description: "Set metadata-action annotations"
required: false
default: false
set-meta-labels:
type: boolean
description: "Set metadata-action labels"
required: false
default: false
setup-qemu:
type: boolean
description: "Install QEMU static binaries"
Expand Down Expand Up @@ -358,6 +369,30 @@ jobs:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Prepare metadata bake files
id: meta-bake-files
uses: actions/github-script@v7
env:
INPUT_SET-META-ANNOTATIONS: ${{ inputs.set-meta-annotations }}
INPUT_SET-META-LABELS: ${{ inputs.set-meta-labels }}
with:
result-encoding: string
script: |
const os = require('os');
const inpSetMetaAnnotations = core.getBooleanInput('set-meta-annotations');
const inpSetMetaLabels = core.getBooleanInput('set-meta-labels');
let bakeFiles = [`cwd://${{ steps.meta.outputs.bake-file-tags }}`];
if (inpSetMetaAnnotations) {
bakeFiles.push(`cwd://${{ steps.meta.outputs.bake-file-annotations }}`);
}
if (inpSetMetaLabels) {
bakeFiles.push(`cwd://${{ steps.meta.outputs.bake-file-labels }}`);
}
core.info(JSON.stringify(bakeFiles, null, 2));
return bakeFiles.join(os.EOL);
-
name: Build
id: bake
Expand All @@ -366,7 +401,7 @@ jobs:
source: ${{ inputs.bake-source }}
files: |
${{ inputs.bake-files }}
cwd://${{ steps.meta.outputs.bake-file }}
${{ steps.meta-bake-files.outputs.result }}
targets: ${{ inputs.target }}
allow: ${{ inputs.bake-allow }}
no-cache: ${{ inputs.bake-no-cache }}
Expand Down Expand Up @@ -406,8 +441,6 @@ jobs:
images: ${{ inputs.meta-image }}
tags: ${{ inputs.meta-tags }}
flavor: ${{ inputs.meta-flavor }}
labels: ${{ inputs.meta-labels }}
annotations: ${{ inputs.meta-annotations }}
bake-target: ${{ inputs.meta-bake-target }}
-
name: Login to registry
Expand Down

0 comments on commit 52b7d9f

Please sign in to comment.