Skip to content

Commit

Permalink
Add attestation for Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
vickunwu committed Jan 16, 2025
1 parent 58ee7a0 commit 3c5e207
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ concurrency:

jobs:
linux:
permissions:
id-token: write
contents: write
attestations: write
packages: write
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -125,7 +130,9 @@ jobs:
skip-extraction: ${{ steps.cargo-cache.outputs.cache-hit }} && ${{ steps.apt-cache.outputs.cache-hit }}

- name: Build Artifact
uses: docker/bake-action@v6
id: build
# bake-action@v6 seems to have some problems with cross-arch build, so sticks to v5 for now
uses: docker/bake-action@v5
env:
TARGET: ${{matrix.target}}
DOCKER_BUILD_RECORD_UPLOAD: false
Expand All @@ -147,6 +154,28 @@ jobs:
./artifact
!./artifact/*.json
- name: Get image digest
id: image-digest
if: (github.event_name == 'push' || inputs.Docker) && (startsWith(matrix.target, 'x86') || startsWith(matrix.target, 'aarch64'))
run: |
echo "image_digest=$(echo '${{ steps.build.outputs.metadata }}' | jq -r '.image.["containerimage.digest"]')" >> "$GITHUB_OUTPUT"
- name: Attest Dockerhub
uses: actions/attest-build-provenance@v2
if: (github.event_name == 'push' || inputs.Docker) && (startsWith(matrix.target, 'x86') || startsWith(matrix.target, 'aarch64'))
with:
subject-name: index.docker.io/${{github.repository}}
subject-digest: ${{ steps.image-digest.outputs.image_digest }}
push-to-registry: true

- name: Attest GHCR
uses: actions/attest-build-provenance@v2
if: (github.event_name == 'push' || inputs.Docker) && (startsWith(matrix.target, 'x86') || startsWith(matrix.target, 'aarch64'))
with:
subject-name: ghcr.io/${{github.repository}}
subject-digest: ${{ steps.image-digest.outputs.image_digest }}
push-to-registry: true

windows:
name: Build / ${{matrix.target}}
runs-on: windows-latest
Expand Down Expand Up @@ -226,7 +255,7 @@ jobs:
name: Release
permissions:
id-token: write
contents: read
contents: write
attestations: write
if: github.event_name == 'push' || inputs.Release
needs: [linux, windows, macos]
Expand Down Expand Up @@ -262,7 +291,7 @@ jobs:
compress_files "$dir_name"
done
- name: Attest
- name: Attest binary
uses: actions/attest-build-provenance@v2
with:
subject-path: |
Expand Down

0 comments on commit 3c5e207

Please sign in to comment.