Skip to content

Commit

Permalink
Refactor action to support multiple usecases
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Franssen <marco.franssen@philips.com>
  • Loading branch information
marcofranssen committed Dec 22, 2021
1 parent 1489f06 commit 2e451be
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 34 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ jobs:
- name: Generate provenance for Release
uses: philips-labs/slsa-provenance-action@v0.4.0
with:
sub-command: github-release
artifact_path: release-assets
output_path: 'provenance.json'
tag_name: ${{ github.ref_name }}
command: generate
subcommand: github-release
arguments: |
--artifact-path release-assets \
--output-path provenance.json \
--tag-name ${{ github.ref_name }}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
6 changes: 5 additions & 1 deletion .github/workflows/example-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ jobs:
- name: Generate provenance
uses: philips-labs/slsa-provenance-action@v0.4.0
with:
artifact_path: artifact/
command: generate
subcommand: files
arguments: |
--artifact-path artifact/ \
--output-path provenance.json
- name: Upload provenance
uses: actions/upload-artifact@v2
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,12 @@ The easiest way to use this action is to add the following into your workflow fi
- name: Generate provenance for Release
uses: philips-labs/slsa-provenance-action@v0.4.0
with:
artifact_path: release-assets
output_path: 'provenance.json'
tag_name: ${{ github.ref_name }}
command: generate
subcommand: files
arguments: |
--artifact-path release-assets \
--output-path 'provenance.json' \
--tag-name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
```
Expand Down
37 changes: 11 additions & 26 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ branding:
icon: lock
color: purple
inputs:
command:
description: 'The command to use (available options: generate)'
required: false
default: 'generate'
subcommand:
description: 'The subcommand to use when generating provenance'
required: false
default: 'files'
artifact_path:
description: 'path to artifact or directory of artifacts'
required: true
output_path:
description: 'path to write build provenance file'
required: false
default: 'provenance.json'
github_context:
description: 'internal (do not set): the "github" context object in json'
required: true
Expand All @@ -23,29 +20,17 @@ inputs:
description: 'internal (do not set): the "runner" context object in json'
required: true
default: ${{ toJSON(runner) }}
tag_name:
description: |
The github release to generate provenance on.
(if set the artifacts will be downloaded from the release and the provenance will be added as an additional release asset.)
required: false
extra_materials:
description: 'paths to files containing SLSA v0.1 formatted materials (JSON array) in to include in the provenance'
required: false
arguments:
description: 'commandline options for the given subcommand'
required: true
runs:
using: 'docker'
image: 'docker://ghcr.io/philips-labs/slsa-provenance:v0.4.0'
args:
- "generate"
- '${{ inputs.command }}'
- '${{ inputs.subcommand }}'
- "-artifact_path"
- '${{ inputs.artifact_path }}'
- "-output_path"
- '${{ inputs.output_path }}'
- "-github_context"
- "--github-context"
- '${{ inputs.github_context }}'
- "-runner_context"
- "--runner-context"
- '${{ inputs.runner_context }}'
- "-tag_name"
- '${{ inputs.tag_name }}'
- "-extra_materials"
- '${{ inputs.extra_materials }}'
- '${{ inputs.arguments }}'

0 comments on commit 2e451be

Please sign in to comment.