Skip to content

Commit 478a43d

Browse files
authored
Merge pull request #88 from docker/distribute
input to whether distribute the build across multiple runners or not
2 parents 62de965 + 416a47b commit 478a43d

File tree

5 files changed

+104
-4
lines changed

5 files changed

+104
-4
lines changed

.github/workflows/.test-bake.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,3 +408,42 @@ jobs:
408408
output: local
409409
sbom: true
410410
target: hello-cross
411+
412+
bake-aws-nodistrib:
413+
uses: ./.github/workflows/bake.yml
414+
permissions:
415+
contents: read
416+
id-token: write
417+
with:
418+
distribute: false
419+
cache: true
420+
cache-scope: bake-aws-nodistrib
421+
context: test
422+
output: image
423+
push: ${{ github.event_name != 'pull_request' }}
424+
sbom: true
425+
target: hello-cross
426+
meta-images: |
427+
public.ecr.aws/q3b5f1u4/test-docker-action
428+
meta-tags: |
429+
type=raw,value=bake-ghbuilder-nodistrib-${{ github.run_id }}
430+
secrets:
431+
registry-auths: |
432+
- registry: public.ecr.aws
433+
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
434+
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
435+
436+
bake-local-nodistrib:
437+
uses: ./.github/workflows/bake.yml
438+
permissions:
439+
contents: read
440+
id-token: write
441+
with:
442+
distribute: false
443+
artifact-name: bake-nodistrib-output
444+
artifact-upload: true
445+
context: test
446+
output: local
447+
sbom: true
448+
sign: ${{ github.event_name != 'pull_request' }}
449+
target: hello-cross

.github/workflows/.test-build.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,3 +503,42 @@ jobs:
503503
output: local
504504
platforms: linux/amd64,linux/arm64
505505
sbom: true
506+
507+
build-aws-nodistrib:
508+
uses: ./.github/workflows/build.yml
509+
permissions:
510+
contents: read
511+
id-token: write
512+
with:
513+
distribute: false
514+
cache: true
515+
cache-scope: build-aws-nodistrib
516+
file: test/hello.Dockerfile
517+
output: image
518+
platforms: linux/amd64,linux/arm64
519+
push: ${{ github.event_name != 'pull_request' }}
520+
sbom: true
521+
meta-images: |
522+
public.ecr.aws/q3b5f1u4/test-docker-action
523+
meta-tags: |
524+
type=raw,value=build-ghbuilder-nodistrib-${{ github.run_id }}
525+
secrets:
526+
registry-auths: |
527+
- registry: public.ecr.aws
528+
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
529+
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
530+
531+
build-local-nodistrib:
532+
uses: ./.github/workflows/build.yml
533+
permissions:
534+
contents: read
535+
id-token: write
536+
with:
537+
distribute: false
538+
artifact-name: build-nodistrib-output
539+
artifact-upload: true
540+
file: test/hello.Dockerfile
541+
output: local
542+
platforms: linux/amd64,linux/arm64
543+
sbom: true
544+
sign: ${{ github.event_name != 'pull_request' }}

.github/workflows/bake.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
description: "Ubuntu GitHub Hosted Runner to build on (one of auto, amd64, arm64). The auto runner selects the best-matching runner based on target platforms. You can set it to amd64 if your build doesn't require emulation (e.g. cross-compilation)"
99
required: false
1010
default: 'auto'
11+
distribute:
12+
type: boolean
13+
description: "Whether to distribute the build across multiple runners (one platform per runner)"
14+
required: false
15+
default: true
1116
setup-qemu:
1217
type: boolean
1318
description: "Runs the setup-qemu-action step to install QEMU static binaries"
@@ -174,6 +179,7 @@ jobs:
174179
INPUT_MATRIX-SIZE-LIMIT: ${{ env.MATRIX_SIZE_LIMIT }}
175180
INPUT_ACTIONS-ID-TOKEN-SET: ${{ env.ACTIONS_ID_TOKEN_REQUEST_TOKEN != '' && env.ACTIONS_ID_TOKEN_REQUEST_URL != '' }}
176181
INPUT_RUNNER: ${{ inputs.runner }}
182+
INPUT_DISTRIBUTE: ${{ inputs.distribute }}
177183
INPUT_ARTIFACT-UPLOAD: ${{ inputs.artifact-upload }}
178184
INPUT_CONTEXT: ${{ inputs.context }}
179185
INPUT_FILES: ${{ inputs.files }}
@@ -196,6 +202,7 @@ jobs:
196202
const inpActionsIdTokenSet = core.getBooleanInput('actions-id-token-set');
197203
198204
const inpRunner = core.getInput('runner');
205+
const inpDistribute = core.getBooleanInput('distribute');
199206
const inpArtifactUpload = core.getBooleanInput('artifact-upload');
200207
const inpContext = core.getInput('context');
201208
const inpFiles = Util.getInputList('files');
@@ -265,7 +272,7 @@ jobs:
265272
}
266273
267274
const platforms = def.target[target].platforms || [];
268-
if (platforms.length > inpMatrixSizeLimit) {
275+
if (inpDistribute && platforms.length > inpMatrixSizeLimit) {
269276
core.setFailed(`Platforms to build exceed matrix size limit of ${inpMatrixSizeLimit}`);
270277
return;
271278
}
@@ -278,7 +285,7 @@ jobs:
278285
279286
await core.group(`Set includes output`, async () => {
280287
let includes = [];
281-
if (platforms.length === 0) {
288+
if (!inpDistribute || platforms.length === 0) {
282289
includes.push({
283290
index: 0,
284291
runner: runner === 'auto' ? 'ubuntu-24.04' : runner

.github/workflows/build.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
description: "Ubuntu GitHub Hosted Runner to build on (one of auto, amd64, arm64). The auto runner selects the best-matching runner based on target platforms. You can set it to amd64 if your build doesn't require emulation (e.g. cross-compilation)"
99
required: false
1010
default: 'auto'
11+
distribute:
12+
type: boolean
13+
description: "Whether to distribute the build across multiple runners (one platform per runner)"
14+
required: false
15+
default: true
1116
setup-qemu:
1217
type: boolean
1318
description: "Runs the setup-qemu-action step to install QEMU static binaries"
@@ -181,6 +186,7 @@ jobs:
181186
INPUT_MATRIX-SIZE-LIMIT: ${{ env.MATRIX_SIZE_LIMIT }}
182187
INPUT_ACTIONS-ID-TOKEN-SET: ${{ env.ACTIONS_ID_TOKEN_REQUEST_TOKEN != '' && env.ACTIONS_ID_TOKEN_REQUEST_URL != '' }}
183188
INPUT_RUNNER: ${{ inputs.runner }}
189+
INPUT_DISTRIBUTE: ${{ inputs.distribute }}
184190
INPUT_ARTIFACT-UPLOAD: ${{ inputs.artifact-upload }}
185191
INPUT_OUTPUT: ${{ inputs.output }}
186192
INPUT_PLATFORMS: ${{ inputs.platforms }}
@@ -195,6 +201,7 @@ jobs:
195201
const inpActionsIdTokenSet = core.getBooleanInput('actions-id-token-set');
196202
197203
const inpRunner = core.getInput('runner');
204+
const inpDistribute = core.getBooleanInput('distribute');
198205
const inpArtifactUpload = core.getBooleanInput('artifact-upload');
199206
const inpPlatforms = Util.getInputList('platforms');
200207
const inpOutput = core.getInput('output');
@@ -226,7 +233,7 @@ jobs:
226233
return;
227234
}
228235
229-
if (inpPlatforms.length > inpMatrixSizeLimit) {
236+
if (inpDistribute && inpPlatforms.length > inpMatrixSizeLimit) {
230237
core.setFailed(`Platforms to build exceed matrix size limit of ${inpMatrixSizeLimit}`);
231238
return;
232239
}
@@ -239,7 +246,7 @@ jobs:
239246
240247
await core.group(`Set includes output`, async () => {
241248
let includes = [];
242-
if (inpPlatforms.length === 0) {
249+
if (!inpDistribute || inpPlatforms.length === 0) {
243250
includes.push({
244251
index: 0,
245252
runner: runner === 'auto' ? 'ubuntu-24.04' : runner
@@ -438,13 +445,15 @@ jobs:
438445
INPUT_PLATFORM: ${{ matrix.platform }}
439446
INPUT_SBOM-IMAGE: ${{ env.SBOM_IMAGE }}
440447
INPUT_LOCAL-EXPORT-DIR: ${{ env.LOCAL_EXPORT_DIR }}
448+
INPUT_DISTRIBUTE: ${{ inputs.distribute }}
441449
INPUT_ANNOTATIONS: ${{ inputs.annotations }}
442450
INPUT_CACHE: ${{ inputs.cache }}
443451
INPUT_CACHE-SCOPE: ${{ inputs.cache-scope }}
444452
INPUT_CACHE-MODE: ${{ inputs.cache-mode }}
445453
INPUT_LABELS: ${{ inputs.labels }}
446454
INPUT_CONTEXT: ${{ inputs.context }}
447455
INPUT_OUTPUT: ${{ inputs.output }}
456+
INPUT_PLATFORMS: ${{ inputs.platforms }}
448457
INPUT_PUSH: ${{ inputs.push }}
449458
INPUT_SBOM: ${{ inputs.sbom }}
450459
INPUT_TARGET: ${{ inputs.target }}
@@ -463,6 +472,7 @@ jobs:
463472
464473
const inpSbomImage = core.getInput('sbom-image');
465474
const inpLocalExportDir = core.getInput('local-export-dir');
475+
const inpDistribute = core.getBooleanInput('distribute');
466476
467477
const inpAnnotations = core.getMultilineInput('annotations');
468478
const inpCache = core.getBooleanInput('cache');
@@ -471,6 +481,7 @@ jobs:
471481
const inpContext = core.getInput('context');
472482
const inpLabels = core.getMultilineInput('labels');
473483
const inpOutput = core.getInput('output');
484+
const inpPlatforms = core.getInput('platforms');
474485
const inpPush = core.getBooleanInput('push');
475486
const inpSbom = core.getBooleanInput('sbom');
476487
const inpTarget = core.getInput('target');
@@ -502,6 +513,8 @@ jobs:
502513
503514
if (inpPlatform) {
504515
core.setOutput('platform', inpPlatform);
516+
} else if (!inpDistribute && inpPlatforms) {
517+
core.setOutput('platform', inpPlatforms);
505518
}
506519
507520
core.setOutput('sbom', inpSbom ? `generator=${inpSbomImage}` : 'false');

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ on:
228228
| Name | Type | Default | Description |
229229
|------------------------|----------|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
230230
| `runner` | String | `auto` | [Ubuntu GitHub Hosted Runner](https://github.com/actions/runner-images?tab=readme-ov-file#available-images) to build on (one of `auto`, `amd64`, `arm64`). The `auto` runner selects the best-matching runner based on target `platforms`. You can set it to `amd64` if your build doesn't require emulation (e.g. cross-compilation) |
231+
| `distribute` | Bool | `true` | Whether to distribute the build across multiple runners (one platform per runner) |
231232
| `setup-qemu` | Bool | `false` | Runs the `setup-qemu-action` step to install QEMU static binaries |
232233
| `artifact-name` | String | `docker-github-builder-assets` | Name of the uploaded GitHub artifact (for `local` output) |
233234
| `artifact-upload` | Bool | `false` | Upload build output GitHub artifact (for `local` output) |
@@ -335,6 +336,7 @@ on:
335336
| Name | Type | Default | Description |
336337
|------------------------|--------|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
337338
| `runner` | String | `auto` | [Ubuntu GitHub Hosted Runner](https://github.com/actions/runner-images?tab=readme-ov-file#available-images) to build on (one of `auto`, `amd64`, `arm64`). The `auto` runner selects the best-matching runner based on target `platforms`. You can set it to `amd64` if your build doesn't require emulation (e.g. cross-compilation) |
339+
| `distribute` | Bool | `true` | Whether to distribute the build across multiple runners (one platform per runner) |
338340
| `setup-qemu` | Bool | `false` | Runs the `setup-qemu-action` step to install QEMU static binaries |
339341
| `artifact-name` | String | `docker-github-builder-assets` | Name of the uploaded GitHub artifact (for `local` output) |
340342
| `artifact-upload` | Bool | `false` | Upload build output GitHub artifact (for `local` output) |

0 commit comments

Comments
 (0)