You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9287977
Browse filesBrowse the repository at this point in the historyBrowse files
ci(framework-build-base): tag every published digest immutably, refuse a silent re-point
Every digest the publish job pushes, and the digest already published
under a requested sha, now carries its own tag SHA-DIGEST12 that is
never deleted or re-pointed, so a GHCR cleanup of untagged versions or a
rebuild of the same pin never takes a pinned digest away. A rebuild over
a published tag is refused unless replace_published is also true.
Re-anchors the dispatch-gates self-test row for the moved
no-check-families declaration (line 32 to 44).
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jSrcejjpWHd8D1fpmZ
Copy file name to clipboardExpand all lines: .github/workflows/framework-build-base.yml
+105-7Lines changed: 105 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -17,8 +17,20 @@ name: Framework Build Base Image
17
17
# with the PR's Dockerfile and pushes nothing; its job has no packages grant.
18
18
#
19
19
# A tag is written once. A request for a commit whose tag already exists reports
20
-
# the existing digest and builds nothing (dispatch with `rebuild: true` to
21
-
# replace it), so a downstream can ask on every pin move at no cost.
20
+
# the existing digest and builds nothing, so a downstream can ask on every pin
21
+
# move at no cost. Replacing a published tag takes a dispatch with BOTH
22
+
# `rebuild: true` and `replace_published: true`: `rebuild: true` alone over a
23
+
# published tag is refused, naming the digest it would move. A
24
+
# repository_dispatch carries neither input, so it never replaces anything.
25
+
#
26
+
# Every digest this workflow publishes also carries a tag of its own,
27
+
# `<sha>-<the first 12 hex of the digest>`, and that tag is never deleted or
28
+
# re-pointed. A downstream pins this image by digest (cloud's committed
29
+
# .objectstack-base-image), and a registry serves a digest only while some tag
30
+
# holds it: a cleanup of untagged versions, or a replace that moves the `<sha>`
31
+
# tag, would otherwise take the pinned digest away. A request whose `<sha>` tag
32
+
# already exists writes its missing digest tag too, so a digest published
33
+
# before this rule becomes durable the next time it is requested.
22
34
#
23
35
# The image definition always comes from THIS run's checkout of main; only the
24
36
# build context is the requested commit. So a commit that predates this file can
@@ -29,7 +41,7 @@ name: Framework Build Base Image
29
41
# settings (Danger Zone, Change visibility; it cannot be made private again).
30
42
# Until then the anonymous-pull step below is red and names that fix.
31
43
32
-
# dispatch-gates: no-check-families -- the steps are an image build, a registry read and an in-image check script (docker/framework-build-base/check-image.sh, which needs the built image), not named local checks
44
+
# dispatch-gates: no-check-families -- the steps are an image build and push, registry reads and digest-tag writes, and an in-image check script (docker/framework-build-base/check-image.sh, which needs the built image), not named local checks
33
45
34
46
on:
35
47
workflow_dispatch:
@@ -39,7 +51,12 @@ on:
39
51
required: true
40
52
type: string
41
53
rebuild:
42
-
description: 'Rebuild and re-push even when the tag already exists (the digest changes)'
54
+
description: 'Rebuild and re-push even when the tag already exists (the digest changes); over a published tag it also needs replace_published'
55
+
required: false
56
+
type: boolean
57
+
default: false
58
+
replace_published:
59
+
description: 'With rebuild, move a published tag to the new digest (the old digest stays served under its own sha-digest tag; downstream pins must then be rewritten)'
if [ -n "$DIGEST" ] && [ "$REBUILD" != true ]; then
197
-
echo "$REF already exists at $DIGEST; nothing to build (dispatch with rebuild: true to replace it)."
214
+
# A published digest is handed on whatever happens next: the digest-tag
215
+
# step below keeps it served under a tag of its own.
216
+
if [ -n "$DIGEST" ]; then echo "digest=$DIGEST" >> "$GITHUB_OUTPUT"; fi
217
+
if [ -z "$DIGEST" ]; then
218
+
echo "skip=false" >> "$GITHUB_OUTPUT"
219
+
elif [ "$REBUILD" != true ]; then
220
+
echo "$REF already exists at $DIGEST; nothing to build."
198
221
echo "skip=true" >> "$GITHUB_OUTPUT"
199
-
echo "digest=$DIGEST" >> "$GITHUB_OUTPUT"
222
+
elif [ "$REPLACE" != true ]; then
223
+
echo "::error::$REF is published at $DIGEST, and rebuild: true would move it to a new digest. To replace it on purpose, dispatch again with rebuild: true and replace_published: true; then rewrite every downstream pin (cloud: scripts/framework-base-image.sh write, then commit .objectstack-base-image)."
224
+
exit 1
200
225
else
226
+
echo "$REF is published at $DIGEST; replace_published: true, so it is rebuilt and the tag moves. The old digest stays served under its digest tag."
201
227
echo "skip=false" >> "$GITHUB_OUTPUT"
202
228
fi
203
229
230
+
# Every published digest keeps a tag of its own, `<sha>-<12 hex>`, that is
231
+
# never deleted or re-pointed (see the header). The two steps below run the
232
+
# same script: this one for the digest already published under `<sha>`
233
+
# (the backfill, before a replace can move the `<sha>` tag), the next one
234
+
# for the digest this run pushed.
235
+
- name: Keep the published digest served under its own tag
236
+
if: steps.existing.outputs.digest != ''
237
+
id: kept
238
+
env:
239
+
SHA: ${{ steps.sha.outputs.sha }}
240
+
DIGEST: ${{ steps.existing.outputs.digest }}
241
+
run: |
242
+
set -euo pipefail
243
+
if ! printf '%s' "$DIGEST" | grep -Eq '^sha256:[0-9a-f]{64}$'; then
244
+
echo "::error::refusing to tag '$DIGEST': a digest is sha256: followed by 64 lowercase hex"
echo "::error::$TAG holds ${HELD:-nothing}, not $DIGEST. A digest tag is never re-pointed, so nothing was changed; read the tag's history in the package's settings before touching it."
echo "::error::$TAG holds ${HELD:-nothing}, not $DIGEST. A digest tag is never re-pointed, so nothing was changed; read the tag's history in the package's settings before touching it."
344
+
exit 1
345
+
fi
346
+
echo "$TAG holds $DIGEST"
347
+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
348
+
260
349
# The image is for anyone to pull, so it is read back the way a stranger
261
350
# would: logged out. A fresh build is pulled whole and looked inside; an
262
351
# existing tag only has its manifest read, anonymously.
@@ -292,13 +381,22 @@ jobs:
292
381
SKIPPED: ${{ steps.existing.outputs.skip }}
293
382
WALL: ${{ steps.wall.outputs.seconds }}
294
383
PULL: ${{ steps.pull.outcome }}
384
+
BUILT: ${{ steps.build.outputs.digest }}
385
+
PUSHED_TAG: ${{ steps.digest_tag.outputs.tag }}
386
+
KEPT_TAG: ${{ steps.kept.outputs.tag }}
295
387
run: |
296
388
{
297
389
echo "### $IMAGE"
298
390
echo
299
391
echo "- framework commit: \`$SHA\`"
300
392
echo "- tag: \`$IMAGE:$SHA\`"
301
393
echo "- digest: \`${DIGEST:-none}\`"
394
+
if [ -n "$BUILT" ]; then
395
+
echo "- digest tag (never deleted or re-pointed): \`${PUSHED_TAG:-not written}\`"
396
+
if [ -n "$KEPT_TAG" ]; then echo "- the replaced digest stays served under: \`$KEPT_TAG\`"; fi
397
+
else
398
+
echo "- digest tag (never deleted or re-pointed): \`${KEPT_TAG:-not written}\`"
0 commit comments