@@ -125,3 +125,106 @@ jobs:
125125 COSIGN_EXPERIMENTAL : " 1"
126126 run : |
127127 cosign sign --yes docker.io/fontebasso/php-nginx@${{ steps.push.outputs.digest }}
128+
129+ generate-sbom :
130+ name : Generate SBOM
131+ needs : merge-multiarch
132+ runs-on : ubuntu-latest
133+ steps :
134+ - name : Install Syft
135+ uses : anchore/sbom-action@v0
136+ with :
137+ image : fontebasso/php-nginx@${{ needs.merge-multiarch.outputs.digest }}
138+ format : spdx-json
139+ output-file : sbom.spdx.json
140+ registry-username : ${{ secrets.DOCKERHUB_USERNAME }}
141+ registry-password : ${{ secrets.DOCKERHUB_TOKEN }}
142+
143+ - name : Upload SBOM
144+ uses : actions/upload-artifact@v4
145+ with :
146+ name : sbom.spdx.json
147+ path : sbom.spdx.json
148+
149+ attest-sbom :
150+ name : Attest SBOM
151+ needs : [merge-multiarch, generate-sbom]
152+ runs-on : ubuntu-latest
153+ steps :
154+ - name : Log in to Docker Hub
155+ uses : docker/login-action@v3
156+ with :
157+ username : ${{ secrets.DOCKERHUB_USERNAME }}
158+ password : ${{ secrets.DOCKERHUB_TOKEN }}
159+
160+ - name : Download SBOM artifact
161+ uses : actions/download-artifact@v4
162+ with :
163+ name : sbom.spdx.json
164+
165+ - name : Install Cosign
166+ 167+
168+ - name : Attest SBOM with Cosign (OIDC keyless)
169+ env :
170+ COSIGN_EXPERIMENTAL : " 1"
171+ run : |
172+ cosign attest --yes \
173+ --predicate sbom.spdx.json \
174+ --type https://spdx.dev/Document \
175+ docker.io/fontebasso/php-nginx:${{ needs.merge-multiarch.outputs.digest }}
176+
177+ generate-provenance :
178+ name : Generate SLSA Provenance
179+ needs : merge-multiarch
180+ if : startsWith(github.ref, 'refs/tags/')
181+ uses :
slsa-framework/slsa-github-generator/.github/workflows/[email protected] 182+ with :
183+ image : docker.io/fontebasso/php-nginx
184+ digest : ${{ needs.merge-multiarch.outputs.digest }}
185+ secrets :
186+ registry-username : ${{ secrets.DOCKERHUB_USERNAME }}
187+ registry-password : ${{ secrets.DOCKERHUB_TOKEN }}
188+ permissions :
189+ id-token : write
190+ contents : read
191+ packages : write
192+ actions : read
193+
194+ release :
195+ needs : [attest-sbom, generate-provenance]
196+ runs-on : ubuntu-latest
197+ steps :
198+ - name : Download SBOM artifact
199+ uses : actions/download-artifact@v4
200+ with :
201+ name : sbom.spdx.json
202+
203+ - name : Install Cosign
204+ 205+
206+ - name : Download Provenance attestation
207+ run : |
208+ cosign download attestation \
209+ docker.io/fontebasso/php-nginx@${{ needs.merge-multiarch.outputs.digest }} \
210+ --output-file provenance.intoto.jsonl
211+
212+ - name : Generate checksum.txt
213+ run : |
214+ sha256sum sbom.spdx.json provenance.intoto.jsonl > checksum.txt
215+
216+ - name : Sign checksum.txt with Cosign (OIDC keyless)
217+ env :
218+ COSIGN_EXPERIMENTAL : " 1"
219+ run : |
220+ cosign sign-blob --yes --output-signature checksum.txt.sig checksum.txt
221+
222+ - name : Upload Provenance, SBOM, and Checksum (signed) to Release
223+ uses : softprops/action-gh-release@v2
224+ with :
225+ files : |
226+ sbom.spdx.json
227+ provenance.intoto.jsonl
228+ checksum.txt
229+ checksum.txt.sig
230+ continue-on-error : false
0 commit comments