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
3126env :
3227 REGISTRY : ghcr.io
28+ IMAGE_NAME : ${{ inputs.container-name }}
3329
3430jobs :
3531 publish-image :
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
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') }}
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