Skip to content

image-signed-ghat(latest) #31

image-signed-ghat(latest)

image-signed-ghat(latest) #31

name: image-signed-ghat(latest)
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
packages: write
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- name: Log into ghcr.io
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
id: push-step
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
push: true
tags: ghcr.io/${{ github.repository }}:latest
context: .
- name: Install Syft
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
- name: Generate SBOM with Syft
id: sbom-gen
run: |
syft scan registry:ghcr.io/${{ github.repository }}:latest -o json > sbom.json
cat sbom.json
- name: Read SBOM into environment variable
id: sbom-read
run: |
SBOM_CONTENTS=$(cat sbom.json | base64)
echo "SBOM_CONTENTS=${SBOM_CONTENTS}" >> $GITHUB_ENV
- name: Attest image
uses: jhrozek/generate-build-provenance@add_sbom
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.push-step.outputs.digest }}
push-to-registry: true
env:
SBOM_CONTENTS: ${{ env.SBOM_CONTENTS }}