Skip to content

Commit 53e20cd

Browse files
committed
reusable workflow for bake
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 93fe717 commit 53e20cd

File tree

4 files changed

+646
-5
lines changed

4 files changed

+646
-5
lines changed

.github/workflows/.test.yml

Lines changed: 102 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
meta-images: |
3030
public.ecr.aws/q3b5f1u4/test-docker-action
3131
meta-tags: |
32-
type=raw,value=ghbuilder-single-${{ github.run_id }}
32+
type=raw,value=build-ghbuilder-single-${{ github.run_id }}
3333
build-file: test/hello.Dockerfile
3434
build-sbom: true
3535
secrets:
@@ -49,7 +49,7 @@ jobs:
4949
meta-images: |
5050
public.ecr.aws/q3b5f1u4/test-docker-action
5151
meta-tags: |
52-
type=raw,value=ghbuilder-${{ github.run_id }}
52+
type=raw,value=build-ghbuilder-${{ github.run_id }}
5353
build-file: test/hello.Dockerfile
5454
build-sbom: true
5555
build-platforms: linux/amd64,linux/arm64
@@ -102,7 +102,7 @@ jobs:
102102
output: ${{ github.event_name != 'pull_request' && 'registry' || 'cacheonly' }}
103103
meta-images: ghcr.io/docker/github-builder-test
104104
meta-tags: |
105-
type=raw,value=${{ github.run_id }}
105+
type=raw,value=build-${{ github.run_id }}
106106
build-file: test/hello.Dockerfile
107107
build-sbom: true
108108
build-platforms: linux/amd64,linux/arm64
@@ -122,7 +122,7 @@ jobs:
122122
output: ${{ github.event_name != 'pull_request' && 'registry' || 'cacheonly' }}
123123
meta-images: registry-1-stage.docker.io/docker/github-builder-test
124124
meta-tags: |
125-
type=raw,value=${{ github.run_id }}
125+
type=raw,value=build-${{ github.run_id }}
126126
build-file: test/hello.Dockerfile
127127
build-sbom: true
128128
build-platforms: linux/amd64,linux/arm64
@@ -163,7 +163,7 @@ jobs:
163163
ghcr.io/docker/github-builder-test
164164
public.ecr.aws/q3b5f1u4/test-docker-action
165165
meta-tags: |
166-
type=raw,value=${{ github.run_id }},prefix=ghcr-and-aws-
166+
type=raw,value=${{ github.run_id }},prefix=build-ghcr-and-aws-
167167
build-file: test/hello.Dockerfile
168168
build-sbom: true
169169
build-platforms: linux/amd64,linux/arm64
@@ -218,3 +218,100 @@ jobs:
218218
for (const cmd of cosignVerifyCommands) {
219219
await exec.exec(cmd);
220220
}
221+
222+
bake-aws:
223+
uses: ./.github/workflows/bake.yml
224+
permissions:
225+
contents: read
226+
packages: write
227+
id-token: write
228+
with:
229+
context: test
230+
target: hello-cross
231+
output: ${{ github.event_name != 'pull_request' && 'registry' || 'cacheonly' }}
232+
meta-images: |
233+
public.ecr.aws/q3b5f1u4/test-docker-action
234+
meta-tags: |
235+
type=raw,value=bake-ghbuilder-${{ github.run_id }}
236+
bake-sbom: true
237+
secrets:
238+
registry-auths: |
239+
- registry: public.ecr.aws
240+
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
241+
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
242+
243+
bake-aws-verify:
244+
runs-on: ubuntu-latest
245+
if: ${{ github.event_name != 'pull_request' }}
246+
needs:
247+
- bake-aws
248+
steps:
249+
-
250+
name: Install Cosign
251+
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
252+
with:
253+
cosign-release: ${{ needs.bake-aws.outputs.cosign-version }}
254+
-
255+
name: Login to registry
256+
uses: docker/login-action@v3
257+
with:
258+
registry: public.ecr.aws
259+
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
260+
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
261+
-
262+
name: Verify signatures
263+
uses: actions/github-script@v8
264+
env:
265+
INPUT_COSIGN-VERSION: ${{ needs.bake-aws.outputs.cosign-version }}
266+
INPUT_COSIGN-VERIFY-COMMANDS: ${{ needs.bake-aws.outputs.cosign-verify-commands }}
267+
with:
268+
script: |
269+
const cosignVersion = core.getInput('cosign-version');
270+
core.info(`Cosign version used by Docker GitHub Builder: ${cosignVersion}`);
271+
const cosignVerifyCommands = core.getMultilineInput('cosign-verify-commands');
272+
for (const cmd of cosignVerifyCommands) {
273+
await exec.exec(cmd);
274+
}
275+
276+
bake-local:
277+
uses: ./.github/workflows/bake.yml
278+
permissions:
279+
contents: read
280+
packages: write
281+
id-token: write
282+
with:
283+
context: test
284+
target: hello-cross
285+
output: ${{ github.event_name != 'pull_request' && 'local' || 'cacheonly' }}
286+
bake-sbom: true
287+
288+
bake-local-verify:
289+
runs-on: ubuntu-latest
290+
if: ${{ github.event_name != 'pull_request' }}
291+
needs:
292+
- bake-local
293+
steps:
294+
-
295+
name: Install Cosign
296+
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
297+
with:
298+
cosign-release: ${{ needs.bake-local.outputs.cosign-version }}
299+
-
300+
name: Download artifact
301+
uses: actions/download-artifact@v5
302+
with:
303+
name: ${{ needs.bake-local.outputs.artifact-name }}
304+
-
305+
name: Verify signatures
306+
uses: actions/github-script@v8
307+
env:
308+
INPUT_COSIGN-VERSION: ${{ needs.bake-local.outputs.cosign-version }}
309+
INPUT_COSIGN-VERIFY-COMMANDS: ${{ needs.bake-local.outputs.cosign-verify-commands }}
310+
with:
311+
script: |
312+
const cosignVersion = core.getInput('cosign-version');
313+
core.info(`Cosign version used by Docker GitHub Builder: ${cosignVersion}`);
314+
const cosignVerifyCommands = core.getMultilineInput('cosign-verify-commands');
315+
for (const cmd of cosignVerifyCommands) {
316+
await exec.exec(cmd);
317+
}

0 commit comments

Comments
 (0)