Skip to content

Commit 4fd21ce

Browse files
committed
build: add remaining build inputs
Signed-off-by: CrazyMax <[email protected]>
1 parent 4efdeeb commit 4fd21ce

File tree

1 file changed

+71
-17
lines changed

1 file changed

+71
-17
lines changed

.github/workflows/build.yml

Lines changed: 71 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ on:
5454
type: string
5555
description: "QEMU static binaries Docker image (e.g. tonistiigi/binfmt:latest)"
5656
required: false
57+
# same as docker/build-push-action inputs
58+
build-annotations:
59+
type: string
60+
description: "List of annotation to set to the image"
61+
required: false
5762
build-args:
5863
type: string
5964
description: "List of build-time variables"
@@ -62,6 +67,10 @@ on:
6267
type: string
6368
description: "Path to the Dockerfile"
6469
required: false
70+
build-labels:
71+
type: string
72+
description: "List of metadata for an image"
73+
required: false
6574
build-output:
6675
type: string
6776
description: "Build output destination (one of cacheonly, registry, local)"
@@ -71,10 +80,27 @@ on:
7180
type: string
7281
description: "List of target platforms to build"
7382
required: false
83+
build-pull:
84+
type: boolean
85+
description: "Always attempt to pull all referenced images"
86+
required: false
87+
default: false
7488
build-sbom:
7589
type: string
7690
description: "Generate SBOM attestation for the build (shorthand for --attest=type=sbom)"
7791
required: false
92+
build-shm-size:
93+
type: string
94+
description: "Size of /dev/shm (e.g., 2g)"
95+
required: false
96+
build-target:
97+
type: string
98+
description: "Sets the target stage to build"
99+
required: false
100+
build-ulimit:
101+
type: string
102+
description: "Ulimit options (e.g., nofile=1024:1024)"
103+
required: false
78104
secrets:
79105
registry-auths:
80106
description: "Registry authentication details as YAML objects"
@@ -96,6 +122,17 @@ jobs:
96122
packages: write # needed for pushing the images to GitHub Packages
97123
id-token: write # needed for signing the images with GitHub OIDC Token
98124
steps:
125+
-
126+
name: Docker meta
127+
id: meta
128+
if: ${{ inputs.build-output == 'registry' }}
129+
uses: docker/metadata-action@v5
130+
with:
131+
images: ${{ inputs.meta-images }}
132+
tags: ${{ inputs.meta-tags }}
133+
flavor: ${{ inputs.meta-flavor }}
134+
labels: ${{ inputs.meta-labels }}
135+
annotations: ${{ inputs.meta-annotations }}
99136
-
100137
name: Prepare
101138
id: prepare
@@ -106,13 +143,27 @@ jobs:
106143
INPUT_CACHE-MODE: ${{ inputs.cache-mode }}
107144
INPUT_META-IMAGES: ${{ inputs.meta-images }}
108145
INPUT_BUILD-OUTPUT: ${{ inputs.build-output }}
146+
INPUT_BUILD-ANNOTATIONS: ${{ inputs.build-annotations }}
147+
INPUT_SET-META-ANNOTATIONS: ${{ inputs.set-meta-annotations }}
148+
INPUT_META-ANNOTATIONS: ${{ steps.meta.outputs.annotations }}
149+
INPUT_BUILD-LABELS: ${{ inputs.build-labels }}
150+
INPUT_SET-META-LABELS: ${{ inputs.set-meta-labels }}
151+
INPUT_META-LABELS: ${{ steps.meta.outputs.labels }}
152+
INPUT_BUILD-TARGET: ${{ inputs.build-target }}
109153
with:
110154
script: |
111155
const inpLocalExportDir = core.getInput('local-export-dir');
112156
const inpCache = core.getBooleanInput('cache');
113157
const inpCacheMode = core.getInput('cache-mode');
114158
const inpMetaImages = core.getMultilineInput('meta-images');
115159
const inpBuildOutput = core.getInput('build-output');
160+
const inpSetMetaAnnotations = core.getBooleanInput('set-meta-annotations');
161+
const inpBuildAnnotations = core.getMultilineInput('build-annotations');
162+
const inpMetaAnnotations = core.getMultilineInput('meta-annotations');
163+
const inpSetMetaLabels = core.getBooleanInput('set-meta-labels');
164+
const inpBuildLabels = core.getMultilineInput('build-labels');
165+
const inpMetaLabels = core.getMultilineInput('meta-labels');
166+
const inpBuildTarget = core.getInput('build-target');
116167
117168
switch (inpBuildOutput) {
118169
case 'cacheonly':
@@ -135,6 +186,16 @@ jobs:
135186
core.setOutput('cache-from', `type=gha,scope=docker-github-builder`);
136187
core.setOutput('cache-to', `type=gha,scope=docker-github-builder,mode=${inpCacheMode}`);
137188
}
189+
190+
if (inpSetMetaAnnotations && inpMetaAnnotations.length > 0) {
191+
inpBuildAnnotations.push(...inpMetaAnnotations);
192+
}
193+
core.setOutput('annotations', inpBuildAnnotations.join('\n'));
194+
195+
if (inpSetMetaLabels && inpMetaLabels.length > 0) {
196+
inpBuildLabels.push(...inpMetaLabels);
197+
}
198+
core.setOutput('labels', inpBuildLabels.join('\n'));
138199
-
139200
name: Set up QEMU
140201
uses: docker/setup-qemu-action@v3
@@ -153,32 +214,25 @@ jobs:
153214
uses: crazy-max/docker-login-action@dockerhub-oidc
154215
with:
155216
registry-auth: ${{ secrets.registry-auths }}
156-
-
157-
name: Docker meta
158-
id: meta
159-
if: ${{ inputs.build-output == 'registry' }}
160-
uses: docker/metadata-action@v5
161-
with:
162-
images: ${{ inputs.meta-images }}
163-
tags: ${{ inputs.meta-tags }}
164-
flavor: ${{ inputs.meta-flavor }}
165-
labels: ${{ inputs.meta-labels }}
166-
annotations: ${{ inputs.meta-annotations }}
167217
-
168218
name: Build
169219
id: build
170220
uses: docker/build-push-action@v6
171221
with:
222+
annotations: ${{ steps.prepare.outputs.annotations }}
172223
build-args: ${{ inputs.build-args }}
173-
file: ${{ inputs.build-file }}
174-
platforms: ${{ inputs.build-platforms }}
175-
outputs: ${{ steps.prepare.outputs.output }}
176224
cache-from: ${{ steps.prepare.outputs.cache-from }}
177225
cache-to: ${{ steps.prepare.outputs.cache-to }}
226+
file: ${{ inputs.build-file }}
227+
labels: ${{ steps.prepare.outputs.labels }}
228+
outputs: ${{ steps.prepare.outputs.output }}
229+
platforms: ${{ inputs.build-platforms }}
178230
provenance: mode=max,version=v1
231+
pull: ${{ inputs.build-pull }}
179232
sbom: ${{ inputs.build-sbom }}
180-
labels: ${{ inputs.set-meta-labels && steps.meta.outputs.labels || '' }}
181-
annotations: ${{ inputs.set-meta-annotations && steps.meta.outputs.annotations || '' }}
233+
shm-size: ${{ inputs.build-shm-size }}
234+
target: ${{ inputs.build-target }}
235+
ulimit: ${{ inputs.build-ulimit }}
182236
github-token: ${{ secrets.github-token || github.token }}
183237
env:
184238
BUILDKIT_MULTI_PLATFORM: 1
@@ -285,6 +339,6 @@ jobs:
285339
if: ${{ inputs.build-output == 'local' }}
286340
uses: actions/upload-artifact@v4
287341
with:
288-
name: docker-github-builder-output
342+
name: docker-github-builder-assets
289343
path: ${{ env.LOCAL_EXPORT_DIR }}
290344
if-no-files-found: error

0 commit comments

Comments
 (0)