-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (117 loc) · 4.3 KB
/
builder_example_slsa3.yml
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Copyright 2023 SLSA Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: SLSA 3 Example builder
permissions: {}
on:
workflow_call:
inputs:
artifact:
description: "Artifact name to build"
required: true
type: string
content:
description: "Artifact content to build"
required: true
type: string
username:
description: "Username for a registry"
default: "bot-account"
required: false
type: string
# NOTE: the additional inputs below are to support additional
# functionality of the workflow.
rekor-log-public:
description: "Allow publication of your repository name on the public Rekor log"
required: false
type: boolean
default: false
secrets:
password:
required: false
description: "Password for a registry"
token:
description: "Token for a registry or GitHub"
required: false
outputs:
artifact:
description: "Name of the artifact built"
value: "${{ fromJSON(jobs.slsa-run.outputs.build-artifacts-outputs).artifact }}"
status:
description: "Status of the build"
value: "${{ fromJSON(jobs.slsa-run.outputs.build-artifacts-outputs).status }}"
provenance-download-name:
description: "The name of the provenance attestation uploaded to the workflow run."
value: ${{ jobs.slsa-run.outputs.attestations-download-name }}
provenance-download-sha256:
description: "The sha256 of the provenance attestation uploaded to the workflow run."
value: ${{ jobs.slsa-run.outputs.attestations-download-sha256 }}
jobs:
slsa-setup:
permissions:
id-token: write # For token creation.
outputs:
slsa-token: ${{ steps.generate.outputs.slsa-token }}
runs-on: ubuntu-latest
steps:
- name: Generate the token
id: generate
uses: slsa-framework/slsa-github-generator/actions/delegator/[email protected]
with:
slsa-workflow-recipient: "delegator_generic_slsa3.yml"
slsa-rekor-log-public: ${{ inputs.rekor-log-public }}
slsa-runner-label: "ubuntu-latest"
slsa-build-action-path: "./internal/callback_action"
slsa-workflow-inputs: ${{ toJson(inputs) }}
slsa-workflow-masked-inputs: username
slsa-run:
needs: [slsa-setup]
permissions:
id-token: write # For signing.
contents: write # For asset uploads.
packages: write # For package uploads.
actions: read # For the entrypoint.
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
slsa-token: ${{ needs.slsa-setup.outputs.slsa-token }}
secrets:
secret1: ${{ inputs.password }}
secret2: ${{ inputs.token }}
publish:
needs: [slsa-run]
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write # For asset uploads.
runs-on: ubuntu-latest
steps:
- name: Download provenance
uses: slsa-framework/slsa-github-generator/actions/delegator/[email protected]
with:
name: ${{ needs.slsa-run.outputs.attestations-download-name }}
sha256: ${{ needs.slsa-run.outputs.attestations-download-sha256 }}
- name: Upload
env:
GH_TOKEN: ${{ github.token }}
OUT: ${{ needs.slsa-run.outputs.attestations-download-name }}
REF: ${{ github.ref }}
run: |
set -euo pipefail
# Get the tag.
tag="$(echo $REF | cut -d '/' -f3-)"
# List attestations.
find "$OUT" -type f | tee ./FILES
# Upload attestations.
while IFS= read -r line; do
file="$line"
echo "Found attestation: $file"
done < FILES