SLSA generic generator #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SLSA generic generator | |
on: | |
workflow_dispatch: | |
release: | |
types: [created] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
digests: ${{ steps.generate-hash.outputs.digests }} | |
steps: | |
- uses: actions/checkout@v4 | |
# Step 1: Ensure artifacts (copying maze0.py to an artifact file). | |
- name: Ensure artifacts | |
run: | | |
cp maze0.py artifact1 | |
echo "This is a generated artifact" > artifact2 | |
# Step 2: Generate the provenance subjects. | |
- name: Generate subject for provenance | |
id: generate-hash | |
run: | | |
set -euo pipefail | |
# List the artifacts the provenance will refer to. | |
files=$(ls artifact1 artifact2) | |
# Generate the subjects (base64 encoded). | |
hashes=$(sha256sum $files | base64 -w0) | |
echo "hashes=$hashes" >> $GITHUB_ENV | |
echo "::set-output name=digests::$hashes" | |
provenance: | |
needs: [build] | |
permissions: | |
actions: read # To read the workflow path. | |
id-token: write # To sign the provenance. | |
contents: write # To add assets to a release. | |
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.4.0 | |
with: | |
base64-subjects: "${{ needs.build.outputs.digests }}" | |
upload-assets: true # Optional: Upload to a new release |