Skip to content

Commit

Permalink
Merge pull request #3 from nais/add_image_ref_check
Browse files Browse the repository at this point in the history
feat(action): validate image ref and set output sbom
  • Loading branch information
ybelMekk authored Jun 9, 2023
2 parents 14bc339 + 6087ee0 commit 53b7a99
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
id: "build_push"
...
- name: "Attest and sign"
uses: 'nais/attest-sign@v1.0.0'
uses: 'nais/attest-sign@v1.x.x'
with:
image_ref: ${{ env.registry }}/${{ env.image }}@${{ steps.build_push.outputs.digest }}
```
20 changes: 19 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,27 @@ branding:
color: 'green'
inputs:
image_ref:
description: 'image ref, i.e. "europe-north1-docker.pkg.dev/nais-io/nais/images/canary-deployer@sha256:eac1f85bee008dfe4ca0eadd1f32256946a171b445d129dba8f00cc67d43582b"'
description: |
'form <image>@<digest>'
'image ref, i.e. "europe-north1-docker.pkg.dev/nais-io/nais/images/canary-deployer@sha256:eac1f85bee008dfe4ca0eadd1f32256946a171b445d129dba8f00cc67d43582b"'
required: true
sbom:
description: 'existing SBOM in cyclonedx format'
default: 'auto-generate-for-me-please.json'
outputs:
sbom:
description: 'SBOM.json in cyclonedx format'
value: ${{ steps.set-outputs.outputs.SBOM }}
runs:
using: 'composite'
steps:
- name: 'Validate image ref'
run: |
if [[ ${{ inputs.image_ref }} != *@sha256:* ]]; then
echo "Image must be in the form of <image>@<digest>"
exit 1
fi
shell: 'bash'
- name: 'Install cosign'
uses: 'sigstore/cosign-installer@dd6b2e2b610a11fd73dd187a43d57cc1394e35f9' # ratchet:sigstore/[email protected]
with:
Expand All @@ -30,3 +43,8 @@ runs:
run: |
cosign sign --yes "${{ inputs.image_ref }}"
cosign attest --yes --predicate "${{ inputs.sbom }}" --type cyclonedx "${{ inputs.image_ref }}"
- name: Set outputs
shell: bash
id: set-outputs
run: |
echo "SBOM=${{ inputs.sbom }}" >> $GITHUB_OUTPUT

0 comments on commit 53b7a99

Please sign in to comment.