forked from docker/github-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (66 loc) · 2.53 KB
/
Copy pathverify.yml
File metadata and controls
70 lines (66 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: verify
on:
workflow_call:
inputs:
builder-outputs:
type: string
description: "JSON build outputs from Docker GitHub Builder reusable workflows"
required: true
secrets:
registry-auths:
description: "Registry authentication details as YAML objects"
required: false
jobs:
verify:
runs-on: ubuntu-latest
steps:
-
name: Extract builder outputs
id: vars
uses: actions/github-script@v8
env:
INPUT_BUILDER-OUTPUTS: ${{ inputs.builder-outputs }}
with:
script: |
const builderOutputs = JSON.parse(core.getInput('builder-outputs'));
core.info(JSON.stringify(builderOutputs, null, 2));
const cosignVersion = builderOutputs['cosign-version'];
const cosignVerifyCommands = builderOutputs['cosign-verify-commands'];
const artifactName = builderOutputs['artifact-name'];
const outputType = builderOutputs['output-type'];
if (!cosignVersion || !cosignVerifyCommands || !artifactName || !outputType) {
throw new Error('Missing required build outputs for verification');
}
core.setOutput('cosign-version', cosignVersion);
core.setOutput('cosign-verify-commands', cosignVerifyCommands);
core.setOutput('artifact-name', artifactName);
core.setOutput('output-type', outputType);
-
name: Install Cosign
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
with:
cosign-release: ${{ steps.vars.outputs.cosign-version }}
-
name: Login to registry
if: ${{ steps.vars.outputs.output-type == 'image' }}
# TODO: switch to docker/login-action when OIDC is supported
uses: crazy-max/docker-login-action@dockerhub-oidc
with:
registry-auth: ${{ secrets.registry-auths }}
-
name: Download artifact
if: ${{ steps.vars.outputs.output-type == 'local' }}
uses: actions/download-artifact@v6
with:
pattern: ${{ steps.vars.outputs.artifact-name }}*
merge-multiple: true
-
name: Verify signatures
uses: actions/github-script@v8
env:
INPUT_COSIGN-VERIFY-COMMANDS: ${{ steps.vars.outputs.cosign-verify-commands }}
with:
script: |
for (const cmd of core.getMultilineInput('cosign-verify-commands')) {
await exec.exec(cmd);
}