Skip to content

Update Dependencies (#262) #32

Update Dependencies (#262)

Update Dependencies (#262) #32

Workflow file for this run

name: Publish Trivy Polr Adapter
on:
push:
tags:
- 'v*'
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
publish-images:
runs-on: ubuntu-latest
permissions:
packages: write
id-token: write
outputs:
digest: ${{ steps.digest.outputs.digest }}
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Set up Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # v0.29.0
with:
scan-type: 'fs'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
- name: Install Cosign
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
- name: Set version
run: |
set -e
TAG=${{ github.ref_name }}
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
- name: Publish Image
shell: bash
id: ko-publish
env:
REGISTRY_USERNAME: ${{ github.repository_owner }}
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
COSIGN_REPOSITORY: ghcr.io/${{ github.repository_owner }}/sbom/trivy-operator-polr-adapter
run: |
set -e
echo "digest=$(make ko-publish)" >> $GITHUB_OUTPUT
- name: Download cyclonedx-gomod
uses: CycloneDX/gh-gomod-generate-sbom@efc74245d6802c8cefd925620515442756c70d8f #v2.0
with:
version: v1
- shell: bash
name: Generate SBOM
run: cyclonedx-gomod app -licenses -json -output trivy-operator-polr-adapter-bom.cdx.json -main .
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: trivy-operator-polr-adapter-bom-cdx
path: trivy-operator-polr-adapter-bom.cdx.json
- shell: bash
env:
COSIGN_REPOSITORY: ghcr.io/${{ github.repository_owner }}/signatures/trivy-operator-polr-adapter
run: |
set -e
cosign sign --yes \
-a "repo=${{ github.repository }}" \
-a "workflow=${{ github.workflow }}" \
-a "ref=${{ github.sha }}" \
${{ steps.ko-publish.outputs.digest }}
- shell: bash
env:
COSIGN_REPOSITORY: ghcr.io/${{ github.repository_owner }}/sbom/trivy-operator-polr-adapter
run: |
cosign attach sbom --sbom ./trivy-operator-polr-adapter-bom.cdx.json --type cyclonedx ${{ steps.ko-publish.outputs.digest }}
- shell: bash
id: digest
run: |
echo "The image generated is: ${{ steps.ko-publish.outputs.digest }}"
DIGEST=$(echo ${{ steps.ko-publish.outputs.digest }} | cut -d '@' -f2)
echo "Digest from image is: $DIGEST"
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
generate-provenance:
needs: publish-images
permissions:
id-token: write # To sign the provenance.
packages: write # To upload assets to release.
actions: read # To read the workflow path.
# NOTE: The container generator workflow is not officially released as GA.
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
image: ghcr.io/${{ github.repository_owner }}/trivy-operator-polr-adapter
digest: "${{ needs.publish-images.outputs.digest }}"
registry-username: ${{ github.repository_owner }}
secrets:
registry-password: ${{ secrets.CR_PAT }}