|
79 | 79 | packages: write # needed for pushing the images to GitHub Packages |
80 | 80 | id-token: write # needed for signing the images with GitHub OIDC Token |
81 | 81 | steps: |
| 82 | + - |
| 83 | + name: Validate |
| 84 | + uses: actions/github-script@v7 |
| 85 | + env: |
| 86 | + INPUT_META-IMAGE: ${{ inputs.meta-image }} |
| 87 | + with: |
| 88 | + script: | |
| 89 | + function getInputList(name) { |
| 90 | + return core.getInput(name) ? core.getInput(name).split(/[\r?\n,]+/).filter(x => x !== '') : []; |
| 91 | + } |
| 92 | + if (getInputList('meta-image').length > 1) { |
| 93 | + throw new Error('Only one meta-image is allowed'); |
| 94 | + } |
82 | 95 | - |
83 | 96 | name: Set up Docker Buildx |
84 | 97 | uses: docker/setup-buildx-action@v3 |
@@ -108,8 +121,7 @@ jobs: |
108 | 121 | with: |
109 | 122 | build-args: ${{ inputs.build-args }} |
110 | 123 | platforms: ${{ inputs.build-platforms }} |
111 | | - tags: ${{ steps.meta.outputs.tags }} |
112 | | - outputs: type=image,oci-artifact=true,push=${{ inputs.push }} |
| 124 | + outputs: type=image,"name=${{ inputs.meta-image }}",oci-artifact=true,push-by-digest=true,name-canonical=true,push=${{ inputs.push }} |
113 | 125 | sbom: ${{ inputs.build-sbom }} |
114 | 126 | labels: ${{ inputs.set-meta-labels && steps.meta.outputs.labels || '' }} |
115 | 127 | annotations: ${{ inputs.set-meta-annotations && steps.meta.outputs.annotations || '' }} |
@@ -198,3 +210,29 @@ jobs: |
198 | 210 | }); |
199 | 211 | } |
200 | 212 | } |
| 213 | + - |
| 214 | + name: Create manifest |
| 215 | + if: ${{ inputs.push }} |
| 216 | + uses: actions/github-script@v7 |
| 217 | + env: |
| 218 | + INPUT_TAGS: ${{ steps.meta.outputs.tags }} |
| 219 | + INPUT_IMAGE-DIGEST: ${{ steps.build.outputs.digest }} |
| 220 | + with: |
| 221 | + script: | |
| 222 | + function getInputList(name) { |
| 223 | + return core.getInput(name) ? core.getInput(name).split(/[\r?\n,]+/).filter(x => x !== '') : []; |
| 224 | + } |
| 225 | + |
| 226 | + let createArgs = ['buildx', 'imagetools', 'create']; |
| 227 | + for (const tag of getInputList('tags')) { |
| 228 | + createArgs.push('-t', tag); |
| 229 | + } |
| 230 | + createArgs.push(core.getInput('image-digest')); |
| 231 | + |
| 232 | + await exec.getExecOutput('docker', createArgs, { |
| 233 | + ignoreReturnCode: true |
| 234 | + }).then(res => { |
| 235 | + if (res.stderr.length > 0 && res.exitCode != 0) { |
| 236 | + throw new Error(res.stderr); |
| 237 | + } |
| 238 | + }); |
0 commit comments