Skip to content

Commit 22d3168

Browse files
committed
ci: refactor Docker image build and add provenance attestations
- Replace inline Docker build logic with a reusable workflow for image build and attestation - Use `docker/build-push-action@v6` to build and push holod and holo-bundle images to ghcr.io - Add provenance attestations using `actions/attest-build-provenance@v2` - Images are now pushed to ghcr.io with corresponding provenance metadata Example verification: $ gh attestation verify oci://ghcr.io/holo-routing/holod:latest -R holo-routing/holo Loaded digest sha256:c3b9a8f7979246c6f2c7e8a214189e56d8b43af1eedb19e0c65703762408f0c7 for oci://ghcr.io/holo-routing/holod:latest Loaded 1 attestation from GitHub API The following policy criteria will be enforced: - Predicate type must match:................ https://slsa.dev/provenance/v1 - Source Repository Owner URI must match:... https://github.com/holo-routing - Source Repository URI must match:......... https://github.com/holo-routing/holo - Subject Alternative Name must match regex: (?i)^https://github.com/holo-routing/holo/ - OIDC Issuer must match:................... https://token.actions.githubusercontent.com ✓ Verification succeeded! The following 1 attestation matched the policy criteria - Attestation #1 - Build repo:..... holo-routing/holo - Build workflow:. .github/workflows/ci.yaml@refs/heads/master - Signer repo:.... holo-routing/holo - Signer workflow: .github/workflows/docker-build-and-attest.yml@refs/heads/master Closes #80 Signed-off-by: Renato Westphal <[email protected]>
1 parent 18f6f62 commit 22d3168

File tree

2 files changed

+65
-16
lines changed

2 files changed

+65
-16
lines changed

.github/workflows/ci.yaml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,25 @@ jobs:
8989
- name: Check benchmark builds
9090
run: cargo bench --no-run -p holo-bgp -p holo-ldp -p holo-ospf
9191

92-
push-image:
93-
name: Docker Image Build
94-
runs-on: ubuntu-latest
92+
docker-build-holod:
93+
uses: ./.github/workflows/docker-build-and-attest.yml
9594
if: github.ref == 'refs/heads/master' && github.repository_owner == 'holo-routing'
96-
steps:
97-
- uses: actions/checkout@v4
98-
- uses: docker/login-action@v3
99-
with:
100-
registry: ghcr.io
101-
username: ${{github.actor}}
102-
password: ${{secrets.GITHUB_TOKEN}}
103-
- name: Build and push container image
104-
run: |
105-
docker build . -f docker/Dockerfile.holod --tag ghcr.io/holo-routing/holod:latest
106-
docker push ghcr.io/holo-routing/holod:latest
107-
docker build . -f docker/Dockerfile.holo-bundle --tag ghcr.io/holo-routing/holo-bundle:latest
108-
docker push ghcr.io/holo-routing/holo-bundle:latest
95+
with:
96+
image-name: holod
97+
dockerfile: docker/Dockerfile.holod
98+
permissions:
99+
id-token: write
100+
attestations: write
101+
packages: write
102+
103+
docker-build-holo-bundle:
104+
needs: docker-build-holod
105+
uses: ./.github/workflows/docker-build-and-attest.yml
106+
if: github.ref == 'refs/heads/master' && github.repository_owner == 'holo-routing'
107+
with:
108+
image-name: holo-bundle
109+
dockerfile: docker/Dockerfile.holo-bundle
110+
permissions:
111+
id-token: write
112+
attestations: write
113+
packages: write
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build and Attest Docker Image
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
image-name:
7+
required: true
8+
type: string
9+
dockerfile:
10+
required: true
11+
type: string
12+
13+
jobs:
14+
build-and-attest:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
id-token: write
18+
attestations: write
19+
packages: write
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Login to GitHub Container Registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Build and push image
31+
id: push_image
32+
uses: docker/build-push-action@v6
33+
with:
34+
context: .
35+
file: ${{ inputs.dockerfile }}
36+
push: true
37+
tags: ghcr.io/holo-routing/${{ inputs.image-name }}:latest
38+
39+
- name: Attest image
40+
uses: actions/attest-build-provenance@v2
41+
with:
42+
subject-name: ghcr.io/holo-routing/${{ inputs.image-name }}
43+
subject-digest: ${{ steps.push_image.outputs.digest }}
44+
push-to-registry: true

0 commit comments

Comments
 (0)