Skip to content

Commit bc864eb

Browse files
authored
Merge pull request #169 from crazy-max/image-name-casing
normalize meta-images for build and bake
2 parents c0add33 + edf7213 commit bc864eb

File tree

4 files changed

+76
-10
lines changed

4 files changed

+76
-10
lines changed

.github/workflows/.test-bake.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,3 +621,27 @@ jobs:
621621
- registry: ghcr.io
622622
username: ${{ github.actor }}
623623
password: ${{ secrets.GITHUB_TOKEN }}
624+
625+
bake-ghcr-image-casing:
626+
uses: ./.github/workflows/bake.yml
627+
permissions:
628+
contents: read
629+
id-token: write
630+
packages: write
631+
with:
632+
context: test
633+
output: image
634+
push: ${{ github.event_name != 'pull_request' }}
635+
sbom: true
636+
set: |
637+
*.args.VERSION={{meta.version}}
638+
target: hello-cross
639+
set-meta-annotations: true
640+
meta-images: ghcr.io/docker/GitHub-Builder-Test
641+
meta-tags: |
642+
type=raw,value=bake-image-casing-${{ github.run_id }}
643+
secrets:
644+
registry-auths: |
645+
- registry: ghcr.io
646+
username: ${{ github.actor }}
647+
password: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/.test-build.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,3 +640,27 @@ jobs:
640640
- registry: ghcr.io
641641
username: ${{ github.actor }}
642642
password: ${{ secrets.GITHUB_TOKEN }}
643+
644+
build-ghcr-image-casing:
645+
uses: ./.github/workflows/build.yml
646+
permissions:
647+
contents: read
648+
id-token: write
649+
packages: write
650+
with:
651+
build-args: |
652+
VERSION={{meta.version}}
653+
file: test/hello.Dockerfile
654+
output: image
655+
platforms: linux/amd64,linux/arm64
656+
push: ${{ github.event_name != 'pull_request' }}
657+
sbom: true
658+
set-meta-annotations: true
659+
meta-images: ghcr.io/docker/GitHub-Builder-Test
660+
meta-tags: |
661+
type=raw,value=build-image-casing-${{ github.run_id }}
662+
secrets:
663+
registry-auths: |
664+
- registry: ghcr.io
665+
username: ${{ github.actor }}
666+
password: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/bake.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ jobs:
170170
runs-on: ubuntu-24.04
171171
outputs:
172172
includes: ${{ steps.set.outputs.includes }}
173+
metaImages: ${{ steps.set.outputs.metaImages }}
173174
sign: ${{ steps.set.outputs.sign }}
174175
ghaCacheSign: ${{ steps.set.outputs.ghaCacheSign }}
175176
steps:
@@ -251,6 +252,7 @@ jobs:
251252
INPUT_SBOM-IMAGE: ${{ env.SBOM_IMAGE }}
252253
INPUT_MATRIX-SIZE-LIMIT: ${{ env.MATRIX_SIZE_LIMIT }}
253254
INPUT_ACTIONS-ID-TOKEN-SET: ${{ env.ACTIONS_ID_TOKEN_REQUEST_TOKEN != '' && env.ACTIONS_ID_TOKEN_REQUEST_URL != '' }}
255+
INPUT_META-IMAGES: ${{ inputs.meta-images }}
254256
INPUT_RUNNER: ${{ inputs.runner }}
255257
INPUT_DISTRIBUTE: ${{ inputs.distribute }}
256258
INPUT_ARTIFACT-UPLOAD: ${{ inputs.artifact-upload }}
@@ -275,6 +277,7 @@ jobs:
275277
const inpSbomImage = core.getInput('sbom-image');
276278
const inpMatrixSizeLimit = parseInt(core.getInput('matrix-size-limit'), 10);
277279
const inpActionsIdTokenSet = core.getBooleanInput('actions-id-token-set');
280+
const inpMetaImages = core.getMultilineInput('meta-images');
278281
279282
const inpRunner = core.getInput('runner');
280283
const inpDistribute = core.getBooleanInput('distribute');
@@ -337,6 +340,12 @@ jobs:
337340
core.info(JSON.stringify(envs, null, 2));
338341
});
339342
343+
const metaImages = inpMetaImages.map(image => image.toLowerCase());
344+
await core.group(`Set metaImages output`, async () => {
345+
core.info(JSON.stringify(metaImages, null, 2));
346+
core.setOutput('metaImages', metaImages.join('\n'));
347+
});
348+
340349
let def;
341350
let target;
342351
try {
@@ -494,7 +503,7 @@ jobs:
494503
if: ${{ inputs.output == 'image' }}
495504
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
496505
with:
497-
images: ${{ inputs.meta-images }}
506+
images: ${{ needs.prepare.outputs.metaImages }}
498507
tags: ${{ inputs.meta-tags }}
499508
flavor: ${{ inputs.meta-flavor }}
500509
labels: ${{ inputs.meta-labels }}
@@ -632,7 +641,7 @@ jobs:
632641
INPUT_SET: ${{ inputs.set }}
633642
INPUT_TARGET: ${{ inputs.target }}
634643
INPUT_VARS: ${{ inputs.vars }}
635-
INPUT_META-IMAGES: ${{ inputs.meta-images }}
644+
INPUT_META-IMAGES: ${{ needs.prepare.outputs.metaImages }}
636645
INPUT_META-VERSION: ${{ steps.meta.outputs.version }}
637646
INPUT_META-TAGS: ${{ steps.meta.outputs.tags }}
638647
INPUT_SET-META-ANNOTATIONS: ${{ inputs.set-meta-annotations }}
@@ -826,7 +835,7 @@ jobs:
826835
if: ${{ needs.prepare.outputs.sign == 'true' && inputs.output == 'image' }}
827836
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
828837
env:
829-
INPUT_IMAGE-NAMES: ${{ inputs.meta-images }}
838+
INPUT_IMAGE-NAMES: ${{ needs.prepare.outputs.metaImages }}
830839
INPUT_IMAGE-DIGEST: ${{ steps.get-image-digest.outputs.digest }}
831840
with:
832841
script: |
@@ -958,7 +967,7 @@ jobs:
958967
if: ${{ inputs.output == 'image' }}
959968
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
960969
with:
961-
images: ${{ inputs.meta-images }}
970+
images: ${{ needs.prepare.outputs.metaImages }}
962971
tags: ${{ inputs.meta-tags }}
963972
flavor: ${{ inputs.meta-flavor }}
964973
labels: ${{ inputs.meta-labels }}
@@ -988,7 +997,7 @@ jobs:
988997
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
989998
env:
990999
INPUT_PUSH: ${{ inputs.push }}
991-
INPUT_IMAGE-NAMES: ${{ inputs.meta-images }}
1000+
INPUT_IMAGE-NAMES: ${{ needs.prepare.outputs.metaImages }}
9921001
INPUT_TAG-NAMES: ${{ steps.meta.outputs.tag-names }}
9931002
INPUT_BUILD-OUTPUTS: ${{ toJSON(needs.build.outputs) }}
9941003
INPUT_SET-META-ANNOTATIONS: ${{ inputs.set-meta-annotations }}

.github/workflows/build.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ jobs:
173173
runs-on: ubuntu-24.04
174174
outputs:
175175
includes: ${{ steps.set.outputs.includes }}
176+
metaImages: ${{ steps.set.outputs.metaImages }}
176177
sign: ${{ steps.set.outputs.sign }}
177178
privateRepo: ${{ steps.set.outputs.privateRepo }}
178179
ghaCacheSign: ${{ steps.set.outputs.ghaCacheSign }}
@@ -246,6 +247,7 @@ jobs:
246247
env:
247248
INPUT_MATRIX-SIZE-LIMIT: ${{ env.MATRIX_SIZE_LIMIT }}
248249
INPUT_ACTIONS-ID-TOKEN-SET: ${{ env.ACTIONS_ID_TOKEN_REQUEST_TOKEN != '' && env.ACTIONS_ID_TOKEN_REQUEST_URL != '' }}
250+
INPUT_META-IMAGES: ${{ inputs.meta-images }}
249251
INPUT_RUNNER: ${{ inputs.runner }}
250252
INPUT_DISTRIBUTE: ${{ inputs.distribute }}
251253
INPUT_ARTIFACT-UPLOAD: ${{ inputs.artifact-upload }}
@@ -260,6 +262,7 @@ jobs:
260262
261263
const inpMatrixSizeLimit = parseInt(core.getInput('matrix-size-limit'), 10);
262264
const inpActionsIdTokenSet = core.getBooleanInput('actions-id-token-set');
265+
const inpMetaImages = core.getMultilineInput('meta-images');
263266
264267
const inpRunner = core.getInput('runner');
265268
const inpDistribute = core.getBooleanInput('distribute');
@@ -304,6 +307,12 @@ jobs:
304307
core.info(`privateRepo: ${privateRepo}`);
305308
core.setOutput('privateRepo', privateRepo);
306309
});
310+
311+
const metaImages = inpMetaImages.map(image => image.toLowerCase());
312+
await core.group(`Set metaImages output`, async () => {
313+
core.info(JSON.stringify(metaImages, null, 2));
314+
core.setOutput('metaImages', metaImages.join('\n'));
315+
});
307316
308317
await core.group(`Set includes output`, async () => {
309318
let includes = [];
@@ -387,7 +396,7 @@ jobs:
387396
if: ${{ inputs.output == 'image' }}
388397
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
389398
with:
390-
images: ${{ inputs.meta-images }}
399+
images: ${{ needs.prepare.outputs.metaImages }}
391400
tags: ${{ inputs.meta-tags }}
392401
flavor: ${{ inputs.meta-flavor }}
393402
labels: ${{ inputs.meta-labels }}
@@ -526,7 +535,7 @@ jobs:
526535
INPUT_PUSH: ${{ inputs.push }}
527536
INPUT_SBOM: ${{ inputs.sbom }}
528537
INPUT_TARGET: ${{ inputs.target }}
529-
INPUT_META-IMAGES: ${{ inputs.meta-images }}
538+
INPUT_META-IMAGES: ${{ needs.prepare.outputs.metaImages }}
530539
INPUT_META-VERSION: ${{ steps.meta.outputs.version }}
531540
INPUT_META-TAGS: ${{ steps.meta.outputs.tags }}
532541
INPUT_SET-META-ANNOTATIONS: ${{ inputs.set-meta-annotations }}
@@ -681,7 +690,7 @@ jobs:
681690
if: ${{ needs.prepare.outputs.sign == 'true' && inputs.output == 'image' }}
682691
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
683692
env:
684-
INPUT_IMAGE-NAMES: ${{ inputs.meta-images }}
693+
INPUT_IMAGE-NAMES: ${{ needs.prepare.outputs.metaImages }}
685694
INPUT_IMAGE-DIGEST: ${{ steps.build.outputs.digest }}
686695
with:
687696
script: |
@@ -813,7 +822,7 @@ jobs:
813822
if: ${{ inputs.output == 'image' }}
814823
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
815824
with:
816-
images: ${{ inputs.meta-images }}
825+
images: ${{ needs.prepare.outputs.metaImages }}
817826
tags: ${{ inputs.meta-tags }}
818827
flavor: ${{ inputs.meta-flavor }}
819828
labels: ${{ inputs.meta-labels }}
@@ -842,7 +851,7 @@ jobs:
842851
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
843852
env:
844853
INPUT_PUSH: ${{ inputs.push }}
845-
INPUT_IMAGE-NAMES: ${{ inputs.meta-images }}
854+
INPUT_IMAGE-NAMES: ${{ needs.prepare.outputs.metaImages }}
846855
INPUT_TAG-NAMES: ${{ steps.meta.outputs.tag-names }}
847856
INPUT_BUILD-OUTPUTS: ${{ toJSON(needs.build.outputs) }}
848857
INPUT_ANNOTATIONS: ${{ inputs.annotations }}

0 commit comments

Comments
 (0)