Skip to content

Commit

Permalink
ci: #62 Add cosign image signature + sbom + provenance
Browse files Browse the repository at this point in the history
Signed-off-by: Laurent Broudoux <[email protected]>
  • Loading branch information
lbroudoux committed Dec 3, 2024
1 parent db640a6 commit c17b299
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions .github/workflows/build-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ on:
- '.gitignore'
- 'LICENSE'
- '*.md'
permissions: read-all
permissions:
contents: read
id-token: write # needed for signing the images with GitHub OIDC Token

jobs:
build-verify-package:
runs-on: ubuntu-latest
Expand All @@ -39,6 +42,9 @@ jobs:
echo "PACKAGE_IMAGE=false" >> "$GITHUB_ENV"
fi
- name: Install Cosign
uses: sigstore/[email protected]

- name: Set up QEMU
if: github.repository_owner == 'microcks' && env.PACKAGE_IMAGE == 'true'
uses: docker/setup-qemu-action@v2
Expand All @@ -53,17 +59,32 @@ jobs:
echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USERNAME }} --password-stdin quay.io
BUILDER=buildx-multi-arch
docker buildx inspect $BUILDER || docker buildx create --name=$BUILDER --driver=docker-container --driver-opt=network=host
- name: Build and push container image
id: build-and-push
uses: docker/[email protected]
if: github.repository_owner == 'microcks' && env.PACKAGE_IMAGE == 'true'
with:
context: .
sbom: true
push: true
platforms: linux/amd64,linux/arm64
builder: buildx-multi-arch
file: Dockerfile
labels: |
org.opencontainers.image.revision=${GITHUB_SHA}
org.opencontainers.image.created=${{ steps.date.outputs.date }}
tags: quay.io/microcks/microcks-hub:${{env.IMAGE_TAG}}

- name: Sign the image with GitHub OIDC Token
env:
DIGEST: ${{ steps.build-and-push.outputs.digest }}
TAGS: quay.io/microcks/microcks-hub:${{env.IMAGE_TAG}}
COSIGN_EXPERIMENTAL: "true"
run: |
docker buildx build --push \
--platform=linux/amd64,linux/arm64 \
--builder=buildx-multi-arch \
--provenance=false \
--build-arg TAG=$IMAGE_TAG \
--file Dockerfile \
--label "org.opencontainers.image.revision=${GITHUB_SHA}" \
--label "org.opencontainers.image.created=${{ steps.date.outputs.date }}" \
--tag=quay.io/microcks/microcks-hub:$IMAGE_TAG .
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}

0 comments on commit c17b299

Please sign in to comment.