forked from project-oak/oak
-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (81 loc) · 2.81 KB
/
provenance3.yaml
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
name: Minimal Provenances
on:
push:
branches:
- "stage0verify"
workflow_dispatch:
inputs:
build-config-path:
required: true
type: string
jobs:
get_inputs:
outputs:
# Resolves to a single file which is passed to the SLSA provenance
# generator.
artifact-path: ${{ steps.parse-build-config.outputs.artifact-path }}
# The name of the internal TR package. This must coincide with the
# basename of the buildconfig.
package-name: ${{ steps.parse-build-config.outputs.package-name }}
builder-digest: ${{ steps.builder-digest.outputs.builder-digest }}
runs-on: ubuntu-20.04
steps:
- name: Mount main branch
uses: actions/checkout@v4
- name: Parse build config
id: parse-build-config
run: |
set -o errexit
set -o nounset
set -o xtrace
set -o pipefail
artifact_path="$(tail -1 ${{ inputs.build-config-path }} | grep -oP 'artifact_path = \K(.*)')"
package_name="$(basename ${{ inputs.build-config-path }} .toml)"
echo "artifact-path=${artifact_path}" >> $GITHUB_OUTPUT
echo "package-name=${package_name}" >> $GITHUB_OUTPUT
- name: Get builder image info
id: builder-digest
run: |
set -o errexit
set -o nounset
set -o xtrace
set -o pipefail
source ./scripts/common
digest="$(echo "${DOCKER_IMAGE_REPO_DIGEST}" | cut -d'@' -f2)"
echo "builder-digest=${digest}" >> $GITHUB_OUTPUT
- name: Print values
run: |
echo "${{ steps.parse-build-config.outputs.artifact-path }}"
echo "${{ steps.parse-build-config.outputs.package-name }}"
echo "${{ steps.builder-digest.outputs.builder-digest }}"
generate_provenance:
needs: [get_inputs]
permissions:
id-token: write
attestations: write
contents: read
runs-on: ubuntu-20.04
steps:
- name: Pretend build
id: pretend
run: |
set -o errexit
set -o nounset
set -o xtrace
set -o pipefail
dir="$(dirname ${{ needs.get_inputs.outputs.artifact-path }})"
mkdir -p $dir
echo whatever > ${{ needs.get_inputs.outputs.artifact-path }}
- name: Debug subject path
run: |
echo "${{ needs.get_inputs.outputs.artifact-path }}"
ls -la "${{ needs.get_inputs.outputs.artifact-path }}"
- name: Attest Build Provenance
id: provenance
uses: actions/[email protected]
with:
subject-path: ${{ needs.get_inputs.outputs.artifact-path }}
- name: Show Bundle
run: |
echo "${{ steps.provenance.outputs.bundle-path }}"
ls -la "${{ steps.provenance.outputs.bundle-path }}"