Skip to content

Commit 46d1973

Browse files
committed
build: add remaining build inputs
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 23a491f commit 46d1973

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"
@@ -95,6 +121,17 @@ jobs:
95121
contents: read
96122
id-token: write # needed for signing the images with GitHub OIDC Token
97123
steps:
124+
-
125+
name: Docker meta
126+
id: meta
127+
if: ${{ inputs.build-output == 'registry' }}
128+
uses: docker/metadata-action@v5
129+
with:
130+
images: ${{ inputs.meta-images }}
131+
tags: ${{ inputs.meta-tags }}
132+
flavor: ${{ inputs.meta-flavor }}
133+
labels: ${{ inputs.meta-labels }}
134+
annotations: ${{ inputs.meta-annotations }}
98135
-
99136
name: Prepare
100137
id: prepare
@@ -105,13 +142,27 @@ jobs:
105142
INPUT_CACHE-MODE: ${{ inputs.cache-mode }}
106143
INPUT_META-IMAGES: ${{ inputs.meta-images }}
107144
INPUT_BUILD-OUTPUT: ${{ inputs.build-output }}
145+
INPUT_BUILD-ANNOTATIONS: ${{ inputs.build-annotations }}
146+
INPUT_SET-META-ANNOTATIONS: ${{ inputs.set-meta-annotations }}
147+
INPUT_META-ANNOTATIONS: ${{ steps.meta.outputs.annotations }}
148+
INPUT_BUILD-LABELS: ${{ inputs.build-labels }}
149+
INPUT_SET-META-LABELS: ${{ inputs.set-meta-labels }}
150+
INPUT_META-LABELS: ${{ steps.meta.outputs.labels }}
151+
INPUT_BUILD-TARGET: ${{ inputs.build-target }}
108152
with:
109153
script: |
110154
const inpLocalExportDir = core.getInput('local-export-dir');
111155
const inpCache = core.getBooleanInput('cache');
112156
const inpCacheMode = core.getInput('cache-mode');
113157
const inpMetaImages = core.getMultilineInput('meta-images');
114158
const inpBuildOutput = core.getInput('build-output');
159+
const inpSetMetaAnnotations = core.getBooleanInput('set-meta-annotations');
160+
const inpBuildAnnotations = core.getMultilineInput('build-annotations');
161+
const inpMetaAnnotations = core.getMultilineInput('meta-annotations');
162+
const inpSetMetaLabels = core.getBooleanInput('set-meta-labels');
163+
const inpBuildLabels = core.getMultilineInput('build-labels');
164+
const inpMetaLabels = core.getMultilineInput('meta-labels');
165+
const inpBuildTarget = core.getInput('build-target');
115166
116167
switch (inpBuildOutput) {
117168
case 'cacheonly':
@@ -134,6 +185,16 @@ jobs:
134185
core.setOutput('cache-from', `type=gha,scope=docker-github-builder`);
135186
core.setOutput('cache-to', `type=gha,scope=docker-github-builder,mode=${inpCacheMode}`);
136187
}
188+
189+
if (inpSetMetaAnnotations && inpMetaAnnotations.length > 0) {
190+
inpBuildAnnotations.push(...inpMetaAnnotations);
191+
}
192+
core.setOutput('annotations', inpBuildAnnotations.join('\n'));
193+
194+
if (inpSetMetaLabels && inpMetaLabels.length > 0) {
195+
inpBuildLabels.push(...inpMetaLabels);
196+
}
197+
core.setOutput('labels', inpBuildLabels.join('\n'));
137198
-
138199
name: Set up QEMU
139200
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)