|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
| 3 | +repo="slsa-framework/example-package" |
| 4 | +api_version="X-GitHub-Api-Version: 2022-11-28" |
3 | 5 | # Verify provenance authenticity with slsa-verifier at HEAD
|
| 6 | +download_artifact(){ |
| 7 | + local run_id="$1" |
| 8 | + local artifact_name="$2" |
| 9 | + # Get the artifact ID for 'artifact1' |
| 10 | + artifact_id=$($GH api -H "Accept: application/vnd.github+json" -H "$api_version" "/repos/$repo/actions/runs/$run_id/artifacts" | jq ".artifacts[] | select(.name == \"$artifact_name\") | .id") |
| 11 | + echo "artifact_id:$artifact_id" |
4 | 12 |
|
| 13 | + $GH api -H "Accept: application/vnd.github+json" -H "$api_version" "/repos/$repo/actions/artifacts/$artifact_id/zip" > "$artifact_name.zip" |
| 14 | + unzip "$artifact_name".zip |
| 15 | +} |
| 16 | + |
| 17 | +# Get workflow ID. |
| 18 | +workflow_id=$($GH api -H "Accept: application/vnd.github+json" -H "$api_version" "/repos/$repo/actions/workflows?per_page=100" | jq '.workflows[] | select(.path == ".github/workflows/e2e.generic.schedule.main.multi-uses.slsa3.yml") | .id') |
| 19 | +echo "workflow_id:$workflow_id" |
| 20 | + |
| 21 | +# Get the run ID for the most recent run. |
| 22 | +run_id=$($GH api -H "Accept: application/vnd.github+json" -H "$api_version" "/repos/$repo/actions/workflows/$workflow_id/runs?per_page=1" | jq '.workflow_runs[0].id') |
| 23 | +echo "run_id:$run_id" |
| 24 | + |
| 25 | +download_artifact "$run_id" "artifacts1" |
| 26 | +download_artifact "$run_id" "attestation1.intoto.jsonl" |
5 | 27 |
|
6 | 28 | cd __EXAMPLE_PACKAGE__
|
7 | 29 | # shellcheck source=/dev/null
|
8 | 30 | source "./.github/workflows/scripts/e2e-verify.common.sh"
|
9 | 31 |
|
10 | 32 | # Set THIS_FILE to correspond with the artifact properties
|
11 |
| -export THIS_FILE=e2e.go.workflow_dispatch.main.config-noldflags.slsa3.yml |
| 33 | +export THIS_FILE=e2e.generic.schedule.main.multi-uses.slsa3.yml |
12 | 34 | export BRANCH=main
|
13 | 35 |
|
14 | 36 | # Set BINARY and PROVENANCE
|
15 | 37 | cd -
|
16 |
| -export BINARY=__THIS_REPO__/cli/slsa-verifier/testdata/gha_go/v1.2.2/binary-linux-amd64-workflow_dispatch |
17 |
| -export PROVENANCE=__THIS_REPO__/cli/slsa-verifier/testdata/gha_go/v1.2.2/binary-linux-amd64-workflow_dispatch.intoto.jsonl |
| 38 | +export BINARY=artifact1 |
| 39 | +export PROVENANCE=attestation1.intoto.jsonl |
18 | 40 |
|
19 |
| -GITHUB_REPOSITORY=slsa-framework/example-package verify_provenance_authenticity "./__THIS_REPO__/slsa-verifier" "HEAD" |
| 41 | +GITHUB_REPOSITORY="$repo" verify_provenance_authenticity "./__THIS_repo__/slsa-verifier" "HEAD" |
0 commit comments