Skip to content

Commit d599e4a

Browse files
authored
Merge pull request #46 from advanced-security/container-attest
Update container-publish to use build provenance attestations
2 parents 57a9012 + fa79967 commit d599e4a

File tree

1 file changed

+14
-38
lines changed

1 file changed

+14
-38
lines changed

.github/workflows/container-publish.yml

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,10 @@ on:
2222
description: "Generate and upload SBOM"
2323
type: string
2424
default: "true"
25-
26-
signing:
27-
description: "Sign the image"
28-
type: string
29-
default: "false"
3025

3126
env:
3227
REGISTRY: ghcr.io
28+
IMAGE_NAME: ${{ inputs.container-name }}
3329

3430
jobs:
3531
publish-image:
@@ -39,8 +35,8 @@ jobs:
3935
# to upload SBOM
4036
id-token: write
4137
contents: write
42-
# to upload Docker image
43-
packages: write
38+
packages: write # to upload Docker image
39+
attestations: write # Upload attestations
4440

4541
steps:
4642
- name: Checkout repository
@@ -60,7 +56,7 @@ jobs:
6056
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804
6157
id: meta
6258
with:
63-
images: ${{ env.REGISTRY }}/${{ inputs.container-name }}
59+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
6460
tags: |
6561
# latest / main
6662
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
@@ -70,7 +66,7 @@ jobs:
7066
type=semver,pattern=v{{major}},value=${{ inputs.version }}
7167
type=semver,pattern=v{{major}}.{{minor}},value=${{ inputs.version }}
7268
73-
- name: Build & Publish Container ${{ inputs.container-name }}
69+
- name: Build & Publish Container ${{ env.IMAGE_NAME }}
7470
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
7571
id: build
7672
with:
@@ -89,35 +85,15 @@ jobs:
8985
filePath: '.'
9086
filePattern: '*.spdx.json'
9187

92-
sign-image:
93-
runs-on: ubuntu-latest
94-
needs: publish-image
95-
# Sign the image only if it is being published
96-
if: ${{ inputs.signing == 'true' }}
97-
98-
permissions:
99-
# read the image from GitHub Container Registry
100-
packages: read
101-
102-
steps:
103-
- name: Checkout repository
104-
uses: actions/checkout@v4
105-
106-
- uses: sigstore/cosign-installer@d7d6bc7722e3daa8354c50bcb52f4837da5e9b6a # v3.8.1
88+
# Build provenance attestations
89+
- name: Attest Container Image
90+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
10791
with:
108-
cosign-release: 'v2.4.1'
92+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
93+
subject-digest: ${{ steps.push.outputs.digest }}
94+
push-to-registry: true
10995

110-
- name: Log in to the Container registry
111-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
96+
- name: Attest Container SBOM
97+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
11298
with:
113-
registry: ${{ env.REGISTRY }}
114-
username: ${{ github.actor }}
115-
password: ${{ secrets.GITHUB_TOKEN }}
116-
117-
- name: Sign the published container
118-
# This step uses the identity token to provision an ephemeral certificate against
119-
# the sigstore community Fulcio instance.
120-
run: |
121-
cosign sign --yes \
122-
${{ env.IMAGE_NAME }}@${{ needs.build-publish-image.outputs.digest }}
123-
99+
subject-path:: '*.spdx.json'

0 commit comments

Comments
 (0)