1515 - cron : ' 42 3 2 * *'
1616 workflow_dispatch :
1717
18- permissions :
19- contents : read
20-
2118jobs :
2219 build :
2320 runs-on : ${{ matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
3330 - index : cpu
3431 python : ' 3.14.2-slim'
3532 permissions :
36- contents : read
33+ contents : write # For the tag creation on cpu images
3734 id-token : write # Needed for actions/attest-build-provenance build predicate
3835 attestations : write # Needed for actions/attest-build-provenance attestation upload to repository
3936 artifact-metadata : write # Needed for actions/attest-build-provenance artifact metadata storage records
9289 subject-digest : ${{ steps.build-push.outputs.digest }}
9390 push-to-registry : true
9491
92+ # With org.opencontainers.image.source pointing to this repository Dockerfile FROM updates in pull requests can be scanned
93+ # if the commits have matching tags with the image.
94+ # https://github.blog/changelog/2023-04-13-dependabot-now-supports-fetching-release-notes-and-changelogs-for-docker-images/
95+ # https://octokit.github.io/rest.js/v19#git-create-ref
96+ # https://octokit.github.io/rest.js/v19#git-update-ref
97+ - name : Tag the commit or update tag
98+ if : github.ref == 'refs/heads/main' && matrix.index == 'cpu'
99+ uses : actions/github-script@v8
100+ with :
101+ script : |
102+ try {
103+ await github.rest.git.createRef({
104+ owner: context.repo.owner,
105+ repo: context.repo.repo,
106+ ref: 'refs/tags/${{ steps.build-tag.outputs.tag }}',
107+ sha: context.sha,
108+ });
109+ } catch(e) {
110+ if (e.status === 422) {
111+ await github.rest.git.updateRef({
112+ owner: context.repo.owner,
113+ repo: context.repo.repo,
114+ ref: 'tags/${{ steps.build-tag.outputs.tag }}',
115+ sha: context.sha,
116+ force: true,
117+ });
118+ }
119+ }
120+
95121 merge :
96122 needs : build
97123 runs-on : ubuntu-latest
@@ -101,6 +127,7 @@ jobs:
101127 python : ['3.14.2', '3.14.2-slim']
102128 index : [cu126]
103129 permissions :
130+ contents : write # For the tag creation
104131 id-token : write # Needed for actions/attest-build-provenance build predicate
105132 attestations : write # Needed for actions/attest-build-provenance attestation upload to repository
106133 artifact-metadata : write # Needed for actions/attest-build-provenance artifact metadata storage records
@@ -149,14 +176,6 @@ jobs:
149176 subject-digest : ${{ steps.manifest.outputs.digest }}
150177 push-to-registry : true
151178
152- description :
153- needs : merge
154- # https://github.com/actions/runner-images/blob/main/images/ubuntu-slim/ubuntu-slim-Readme.md
155- runs-on : ubuntu-slim
156- if : github.ref == 'refs/heads/main'
157- permissions :
158- contents : write # For the tag creation
159- steps :
160179 # With org.opencontainers.image.source pointing to this repository Dockerfile FROM updates in pull requests can be scanned
161180 # if the commits have matching tags with the image.
162181 # https://github.blog/changelog/2023-04-13-dependabot-now-supports-fetching-release-notes-and-changelogs-for-docker-images/
@@ -171,22 +190,32 @@ jobs:
171190 await github.rest.git.createRef({
172191 owner: context.repo.owner,
173192 repo: context.repo.repo,
174- ref: 'refs/tags/${{ steps.build-tag .outputs.tag }}',
193+ ref: 'refs/tags/${{ steps.manifest .outputs.tag }}',
175194 sha: context.sha,
176195 });
177196 } catch(e) {
178197 if (e.status === 422) {
179198 await github.rest.git.updateRef({
180199 owner: context.repo.owner,
181200 repo: context.repo.repo,
182- ref: 'tags/${{ steps.build-tag .outputs.tag }}',
201+ ref: 'tags/${{ steps.manifest .outputs.tag }}',
183202 sha: context.sha,
184203 force: true,
185204 });
186205 }
187206 }
188207
189- # Can not use Personal Access Token to update the README. Returns FORBIDDEN.
208+ description :
209+ needs : merge
210+ # https://github.com/actions/runner-images/blob/main/images/ubuntu-slim/ubuntu-slim-Readme.md
211+ runs-on : ubuntu-slim
212+ if : github.ref == 'refs/heads/main'
213+ permissions :
214+ contents : read # To checkout the README.md
215+ steps :
216+ - uses : actions/checkout@v6
217+
218+ # Can not use Personal Access Token to update the README. Returns FORBIDDEN.
190219 - name : Docker Hub Description
191220 uses : peter-evans/dockerhub-description@1b9a80c056b620d92cedb9d9b5a223409c68ddfa # v5.0.0
192221 with :
0 commit comments