Skip to content

Update enterprise-contract/action-validate-image action to v1.0.51 #96

Update enterprise-contract/action-validate-image action to v1.0.51

Update enterprise-contract/action-validate-image action to v1.0.51 #96

Workflow file for this run

name: release
on:
push:
branches:
- main
env:
IMAGE_REGISTRY: ghcr.io
IMAGE_REPO: ${{ github.repository_owner }}/golden-container
IMAGE_TAGS: ${{ github.sha }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
# Needed for signing the container image with GitHub OIDC Token
id-token: write
# Needed to push to ghcr.io registry
packages: write
outputs:
image: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPO }}
digest: ${{ steps.push-image.outputs.digest }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Cosign
uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # v3.1.2
- name: Install Syft
uses: anchore/sbom-action/download-syft@78fc58e266e87a38d4194b2137a3d4e9bcaf7ca1 # v0.14.3
- name: Log in to ghcr
uses: redhat-actions/podman-login@9184318aae1ee5034fbfbacc0388acf12669171f # v1
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Buildah Action
id: build-image
uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2
with:
image: ${{ env.IMAGE_REPO }}
tags: ${{ env.IMAGE_TAGS }}
dockerfiles: ./Containerfile
- name: Push to ghcr
id: push-image
uses: redhat-actions/push-to-registry@9986a6552bc4571882a4a67e016b17361412b4df #v2
with:
registry: ${{ env.IMAGE_REGISTRY }}
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
- name: Sign image with GitHub OIDC Token
run: cosign sign --yes ${IMAGE_REGISTRY}/${IMAGE_REPO}@${DIGEST}
env:
DIGEST: ${{ steps.push-image.outputs.digest }}
- name: Generate and store SBOM
run: |
syft "${IMAGE_REGISTRY}/${IMAGE_REPO}@${DIGEST}" -o spdx-json=sbom-spdx.json
cosign attest --yes --predicate sbom-spdx.json --type spdx "${IMAGE_REGISTRY}/${IMAGE_REPO}@${DIGEST}"
env:
DIGEST: ${{ steps.push-image.outputs.digest }}
provenance:
needs: [build]
permissions:
actions: read # for detecting the Github Actions environment.
id-token: write # for creating OIDC tokens for signing.
packages: write # for uploading attestations.
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
image: ${{ needs.build.outputs.image }}
digest: ${{ needs.build.outputs.digest }}
registry-username: ${{ github.actor }}
secrets:
registry-password: ${{ secrets.GITHUB_TOKEN }}
validate:
needs: [provenance, build]
runs-on: ubuntu-latest
steps:
- name: Validate image
uses: enterprise-contract/[email protected]
with:
image: ${{ needs.build.outputs.image }}@${{ needs.build.outputs.digest }}
identity: https:\/\/github\.com\/(slsa-framework\/slsa-github-generator|${{ github.repository_owner }}\/${{ github.event.repository.name }})\/
issuer: https://token.actions.githubusercontent.com
promote:
runs-on: ubuntu-latest
needs: [validate, build]
steps:
- name: Push latest-validated image tag
run: |
skopeo copy \
--dest-creds=${{ github.actor }}:${{ github.token }} \
docker://${{ needs.build.outputs.image }}@${{ needs.build.outputs.digest }} \
docker://${{ needs.build.outputs.image }}:latest