forked from openai/codex-security
-
Notifications
You must be signed in to change notification settings - Fork 0
621 lines (552 loc) · 24 KB
/
Copy pathcontainer-release.yml
File metadata and controls
621 lines (552 loc) · 24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
name: container-release
on:
pull_request:
paths:
- .dockerignore
- .github/workflows/container-release.yml
- Dockerfile
- Dockerfile.dockerignore
- compose.yaml
- compose.apparmor.yaml
- docker/**
- sdk/typescript/**
push:
tags:
- "container-v*"
workflow_dispatch:
concurrency:
group: container-release-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || 'publish' }}
cancel-in-progress: false
permissions:
contents: read
jobs:
validate:
if: github.repository == 'openai/codex-security'
name: validate-linux-${{ matrix.architecture }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- architecture: amd64
runner: ubuntu-24.04
- architecture: arm64
runner: ubuntu-24.04-arm
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Build native customer image
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
env:
DOCKER_BUILD_RECORD_UPLOAD: "false"
with:
context: .
load: true
platforms: linux/${{ matrix.architecture }}
push: false
tags: codex-security:release-candidate
cache-from: type=gha,scope=codex-security-${{ matrix.architecture }}
cache-to: ${{ github.event_name != 'pull_request' && format('type=gha,mode=max,scope=codex-security-{0}', matrix.architecture) || '' }}
- name: Verify native image and bundled scanner
env:
EXPECTED_ARCHITECTURE: ${{ matrix.architecture }}
shell: bash
run: |
set -euo pipefail
actual_architecture="$(docker image inspect --format '{{.Architecture}}' codex-security:release-candidate)"
if [[ "$actual_architecture" != "$EXPECTED_ARCHITECTURE" ]]; then
echo "Expected a native $EXPECTED_ARCHITECTURE image; found $actual_architecture." >&2
exit 1
fi
docker run --rm codex-security:release-candidate --version
docker run --rm codex-security:release-candidate bulk-scan --help
docker run --rm codex-security:release-candidate info --json
[[ "$(docker run --rm --entrypoint id codex-security:release-candidate -u)" == 10001 ]]
- name: Verify host-aware AppArmor sandbox selection
shell: bash
run: |
set -euo pipefail
docker run --rm --entrypoint /bin/sh codex-security:release-candidate -ec '
command_directory="$(mktemp -d)"
trap '\''rm -rf "$command_directory"'\'' EXIT
printf "%s\\n" "#!/bin/sh" '\''printf "%s\\n" "$@"'\'' > "$command_directory/codex-security"
chmod 755 "$command_directory/codex-security"
actual="$(
PATH="$command_directory:$PATH" \
/usr/local/bin/codex-security-entrypoint \
bulk-scan /input/repositories.csv --output-dir /output
)"
restricted_user_namespaces=
if [ -r /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]; then
IFS= read -r restricted_user_namespaces \
< /proc/sys/kernel/apparmor_restrict_unprivileged_userns || true
fi
apparmor_profile=
if [ -r /proc/self/attr/current ]; then
IFS= read -r apparmor_profile < /proc/self/attr/current || true
fi
if [ "$restricted_user_namespaces" = 1 ] &&
[ "$apparmor_profile" != "codex-security-container (enforce)" ]; then
printf "%s\\n" "$actual" | grep -Fxq features.use_legacy_landlock=true
elif printf "%s\\n" "$actual" | grep -Fxq features.use_legacy_landlock=true; then
printf "%s\\n" "Landlock must not be forced when the preferred sandbox is available." >&2
exit 1
fi
'
- name: Verify hardened Codex command sandbox
shell: bash
run: |
set -euo pipefail
command=(
docker run --rm
--cap-drop ALL
--security-opt no-new-privileges
--security-opt "seccomp=$GITHUB_WORKSPACE/docker/codex-security-seccomp.json"
--entrypoint node
codex-security:release-candidate
/usr/local/lib/node_modules/@openai/codex-security/node_modules/@openai/codex/bin/codex.js
)
if output="$("${command[@]}" sandbox /usr/bin/true 2>&1)"; then
printf '%s\n' "$output"
elif grep -Eq 'bwrap: (Failed to make / slave: Permission denied|loopback: Failed RTM_NEW(ADDR|LINK): Operation not permitted|setting up uid map: Permission denied|No permissions to create a new namespace)' <<< "$output"; then
echo '::notice::This Docker host blocks nested Bubblewrap namespaces; verifying the supported Landlock fallback.'
"${command[@]}" sandbox --enable use_legacy_landlock /usr/bin/true
else
printf 'The hardened Codex sandbox failed unexpectedly:\n%s\n' "$output" >&2
exit 1
fi
- name: Verify host-scoped Git credentials
shell: bash
run: |
set -euo pipefail
docker run --rm \
--entrypoint /bin/sh \
--env GH_TOKEN=SYNTHETIC_GITHUB_TOKEN \
codex-security:release-candidate \
-ec 'actual="$(printf "protocol=https\nhost=github.com\n\n" | /usr/local/bin/codex-security-git-credential get)"; test "$actual" = "$(printf "username=x-access-token\npassword=SYNTHETIC_GITHUB_TOKEN")"; test -z "$(printf "protocol=https\nhost=untrusted.example\n\n" | /usr/local/bin/codex-security-git-credential get)"'
- name: Verify hardened customer Compose configuration
env:
CODEX_SECURITY_IMAGE: codex-security:release-candidate
shell: bash
run: |
set -euo pipefail
mkdir -p results state
chmod 700 results state
printf 'id,repository,revision\n' > repositories.csv
CODEX_SECURITY_USER="$(id -u):$(id -g)"
export CODEX_SECURITY_USER
docker compose config --quiet
docker compose run --rm codex-security --version
if output="$(docker compose run --rm codex-security 2>&1)"; then
echo 'An empty repository CSV must not start a security scan.' >&2
exit 1
else
status=$?
fi
if [[ "$status" -ne 2 ]] || ! grep -Fq 'Multiscan CSV must contain at least one repository.' <<< "$output"; then
printf 'Unexpected empty-repository scan behavior:\n%s\n' "$output" >&2
exit 1
fi
- name: Verify optional hardened AppArmor Compose override
env:
CODEX_SECURITY_IMAGE: codex-security:release-candidate
shell: bash
run: |
set -euo pipefail
CODEX_SECURITY_USER="$(id -u):$(id -g)"
export CODEX_SECURITY_USER
compose=(docker compose -f compose.yaml -f compose.apparmor.yaml)
"${compose[@]}" config --format json |
jq --exit-status '
.services["codex-security"].security_opt as $options |
($options | index("apparmor=codex-security-container")) != null and
($options | index("no-new-privileges:true")) != null and
any($options[]; startswith("seccomp="))
' > /dev/null
if ! docker info --format '{{json .SecurityOptions}}' |
grep -Fq '"name=apparmor"'; then
echo '::notice::This Docker host does not expose AppArmor; the default customer workflow remains available.'
exit 0
fi
sudo install -m 0644 docker/codex-security.apparmor \
/etc/apparmor.d/codex-security-container
sudo apparmor_parser -r -W /etc/apparmor.d/codex-security-container
sudo grep -Fxq 'codex-security-container (enforce)' \
/sys/kernel/security/apparmor/profiles
# The single-quoted program is evaluated inside the customer container.
# shellcheck disable=SC2016
"${compose[@]}" run --rm --entrypoint /bin/sh codex-security -ec '
test "$(cat /proc/self/attr/current)" = "codex-security-container (enforce)"
command_directory="$(mktemp -d)"
trap '\''rm -rf "$command_directory"'\'' EXIT
printf "%s\\n" "#!/bin/sh" '\''printf "%s\\n" "$@"'\'' \
> "$command_directory/codex-security"
chmod 755 "$command_directory/codex-security"
actual="$(
PATH="$command_directory:$PATH" \
/usr/local/bin/codex-security-entrypoint \
bulk-scan /input/repositories.csv --output-dir /output
)"
if printf "%s\\n" "$actual" |
grep -Fxq features.use_legacy_landlock=true; then
printf "%s\\n" "The AppArmor profile must retain the preferred Codex sandbox." >&2
exit 1
fi
'
"${compose[@]}" run --rm --entrypoint node codex-security \
/usr/local/lib/node_modules/@openai/codex-security/node_modules/@openai/codex/bin/codex.js \
sandbox /usr/bin/true
authorize:
if: github.event_name != 'pull_request'
name: authorize-container-publication
needs: validate
runs-on: ubuntu-24.04
timeout-minutes: 10
environment: container
permissions:
contents: read
packages: read
outputs:
image: ${{ steps.release.outputs.image }}
version: ${{ steps.release.outputs.version }}
steps:
- name: Checkout release source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Validate protected release source and version
id: release
shell: bash
run: |
set -euo pipefail
package_version="$(node -p 'require("./sdk/typescript/package.json").version')"
if [[ "$GITHUB_EVENT_NAME" == workflow_dispatch ]]; then
if [[ "$GITHUB_REF" != refs/heads/main ]]; then
echo 'Manual image releases must use the protected main branch.' >&2
exit 1
fi
version="$package_version"
elif [[ "$GITHUB_REF_NAME" =~ ^container-v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
version="${GITHUB_REF_NAME#container-v}"
else
echo 'Container release tags must identify a stable version such as container-v0.1.0.' >&2
exit 1
fi
if [[ "$version" != "$package_version" ]]; then
echo "Container version $version must match the CLI package version $package_version." >&2
exit 1
fi
git fetch --no-tags origin +refs/heads/main:refs/remotes/origin/main
if ! git merge-base --is-ancestor "$GITHUB_SHA" refs/remotes/origin/main; then
echo 'Container releases must be built from a commit on the protected main branch.' >&2
exit 1
fi
printf 'image=ghcr.io/%s\n' "${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT"
- name: Preflight public package and immutable release version
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.release.outputs.version }}
shell: bash
run: |
set -euo pipefail
owner="${GITHUB_REPOSITORY_OWNER,,}"
package="${GITHUB_REPOSITORY#*/}"
endpoint="orgs/$owner/packages/container/$package"
if ! metadata="$(gh api "$endpoint" 2>/dev/null)"; then
echo "::error::A repository administrator must bootstrap ghcr.io/$owner/$package, make the package public, and grant this repository package access before approving publication."
exit 1
fi
if [[ "$(jq -r '.visibility' <<< "$metadata")" != public ]]; then
echo "::error::ghcr.io/$owner/$package must be public before any release image is pushed."
exit 1
fi
sh docker/verify-container-release-version.sh "$endpoint" "$VERSION"
publish-platform:
name: publish-linux-${{ matrix.architecture }}
needs: authorize
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- architecture: amd64
runner: ubuntu-24.04
- architecture: arm64
runner: ubuntu-24.04-arm
steps:
- name: Checkout approved release source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Sign in to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish native image by immutable digest
id: build
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
platforms: linux/${{ matrix.architecture }}
outputs: type=image,name=${{ needs.authorize.outputs.image }},push-by-digest=true,name-canonical=true,push=true
provenance: mode=max
sbom: true
cache-from: type=gha,scope=codex-security-${{ matrix.architecture }}
cache-to: type=gha,mode=max,scope=codex-security-${{ matrix.architecture }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ needs.authorize.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Verify the exact published native image
env:
EXPECTED_ARCHITECTURE: ${{ matrix.architecture }}
IMAGE: ${{ needs.authorize.outputs.image }}
IMAGE_DIGEST: ${{ steps.build.outputs.digest }}
shell: bash
run: |
set -euo pipefail
if [[ ! "$IMAGE_DIGEST" =~ ^sha256:[[:xdigit:]]{64}$ ]]; then
echo 'The registry did not return a valid immutable platform digest.' >&2
exit 1
fi
reference="$IMAGE@$IMAGE_DIGEST"
docker logout ghcr.io
docker pull "$reference"
actual_architecture="$(docker image inspect --format '{{.Architecture}}' "$reference")"
if [[ "$actual_architecture" != "$EXPECTED_ARCHITECTURE" ]]; then
echo "Expected a native $EXPECTED_ARCHITECTURE image; found $actual_architecture." >&2
exit 1
fi
docker run --rm "$reference" --version
docker run --rm "$reference" bulk-scan --help
docker run --rm "$reference" info --json
[[ "$(docker run --rm --entrypoint id "$reference" -u)" == 10001 ]]
- name: Record verified platform digest
env:
IMAGE_DIGEST: ${{ steps.build.outputs.digest }}
shell: bash
run: |
set -euo pipefail
if [[ ! "$IMAGE_DIGEST" =~ ^sha256:[[:xdigit:]]{64}$ ]]; then
echo 'The registry did not return a valid immutable platform digest.' >&2
exit 1
fi
mkdir -p "$RUNNER_TEMP/codex-security-platform-digests"
touch "$RUNNER_TEMP/codex-security-platform-digests/${IMAGE_DIGEST#sha256:}"
- name: Upload platform digest
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: codex-security-image-digest-${{ matrix.architecture }}
path: ${{ runner.temp }}/codex-security-platform-digests/*
if-no-files-found: error
retention-days: 7
compression-level: 0
manifest:
name: publish-and-verify-multiarchitecture-candidate
needs:
- authorize
- publish-platform
runs-on: ubuntu-24.04
timeout-minutes: 30
permissions:
contents: read
packages: write
outputs:
digest: ${{ steps.manifest.outputs.digest }}
candidate: ${{ steps.manifest.outputs.candidate }}
steps:
- name: Checkout approved customer configuration
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Download verified platform digests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: ${{ runner.temp }}/codex-security-platform-digests
pattern: codex-security-image-digest-*
merge-multiple: true
- name: Sign in to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish provisional multiarchitecture candidate
id: manifest
env:
IMAGE: ${{ needs.authorize.outputs.image }}
shell: bash
run: |
set -euo pipefail
mapfile -t digest_files < <(
find "$RUNNER_TEMP/codex-security-platform-digests" \
-maxdepth 1 -type f -printf '%f\n' | sort
)
if [[ "${#digest_files[@]}" -ne 2 ]]; then
echo 'A release must contain exactly one verified amd64 and arm64 image.' >&2
exit 1
fi
references=()
for digest in "${digest_files[@]}"; do
if [[ ! "$digest" =~ ^[[:xdigit:]]{64}$ ]]; then
echo 'The release contains an invalid platform digest.' >&2
exit 1
fi
references+=("$IMAGE@sha256:$digest")
done
candidate="$IMAGE:release-candidate-$GITHUB_SHA"
docker buildx imagetools create \
--tag "$candidate" \
"${references[@]}"
manifest_digest="$(docker buildx imagetools inspect --format '{{.Manifest.Digest}}' "$candidate")"
if [[ ! "$manifest_digest" =~ ^sha256:[[:xdigit:]]{64}$ ]]; then
echo 'The registry did not return a valid multiarchitecture image digest.' >&2
exit 1
fi
printf 'digest=%s\n' "$manifest_digest" >> "$GITHUB_OUTPUT"
printf 'candidate=%s\n' "$candidate" >> "$GITHUB_OUTPUT"
docker buildx imagetools inspect "$candidate" --raw |
jq --exit-status '
[.manifests[] | select(.platform.os == "linux") | .platform.architecture]
| (index("amd64") != null and index("arm64") != null)
' > /dev/null
- name: Verify customers can pull the candidate without GitHub credentials
env:
CANDIDATE: ${{ steps.manifest.outputs.candidate }}
shell: bash
run: |
set -euo pipefail
docker logout ghcr.io
if ! docker pull "$CANDIDATE"; then
echo '::error::The verified candidate cannot be pulled anonymously; no stable release tags have been published.'
exit 1
fi
docker run --rm "$CANDIDATE" --version
docker run --rm "$CANDIDATE" bulk-scan --help
docker run --rm "$CANDIDATE" info --json
- name: Verify hardened customer Compose against the public candidate
env:
CODEX_SECURITY_IMAGE: ${{ steps.manifest.outputs.candidate }}
shell: bash
run: |
set -euo pipefail
mkdir -p results state
chmod 700 results state
printf 'id,repository,revision\n' > repositories.csv
CODEX_SECURITY_USER="$(id -u):$(id -g)"
export CODEX_SECURITY_USER
docker compose config --quiet
docker compose run --rm codex-security --version
if output="$(docker compose run --rm codex-security 2>&1)"; then
echo 'An empty repository CSV must not start a security scan.' >&2
exit 1
else
status=$?
fi
if [[ "$status" -ne 2 ]] || ! grep -Fq 'Multiscan CSV must contain at least one repository.' <<< "$output"; then
printf 'Unexpected empty-repository scan behavior:\n%s\n' "$output" >&2
exit 1
fi
attest:
name: attest-verified-multiarchitecture-candidate
needs:
- authorize
- manifest
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
attestations: write
contents: read
id-token: write
packages: write
steps:
- name: Sign in to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Sign verified multiarchitecture candidate provenance
uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1
with:
push-to-registry: true
subject-name: ${{ needs.authorize.outputs.image }}
subject-digest: ${{ needs.manifest.outputs.digest }}
promote:
name: promote-verified-and-attested-release
needs:
- authorize
- manifest
- attest
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: read
packages: write
steps:
- name: Checkout approved immutable-version verifier
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Sign in to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Promote the verified, attested, immutable image digest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IMAGE: ${{ needs.authorize.outputs.image }}
VERSION: ${{ needs.authorize.outputs.version }}
MANIFEST_DIGEST: ${{ needs.manifest.outputs.digest }}
shell: bash
run: |
set -euo pipefail
if [[ ! "$MANIFEST_DIGEST" =~ ^sha256:[[:xdigit:]]{64}$ ]]; then
echo 'The verified release did not provide a valid immutable digest.' >&2
exit 1
fi
owner="${GITHUB_REPOSITORY_OWNER,,}"
package="${GITHUB_REPOSITORY#*/}"
endpoint="orgs/$owner/packages/container/$package"
sh docker/verify-container-release-version.sh "$endpoint" "$VERSION"
docker buildx imagetools create \
--tag "$IMAGE:$VERSION" \
--tag "$IMAGE:sha-$GITHUB_SHA" \
--tag "$IMAGE:latest" \
"$IMAGE@$MANIFEST_DIGEST"
actual_digest="$(docker buildx imagetools inspect --format '{{.Manifest.Digest}}' "$IMAGE:$VERSION")"
if [[ "$actual_digest" != "$MANIFEST_DIGEST" ]]; then
echo '::error::The promoted stable tag does not reference the verified and attested candidate digest.'
exit 1
fi
- name: Verify the stable release is publicly pullable
env:
IMAGE: ${{ needs.authorize.outputs.image }}
VERSION: ${{ needs.authorize.outputs.version }}
shell: bash
run: |
set -euo pipefail
docker logout ghcr.io
docker pull "$IMAGE:$VERSION"
docker run --rm "$IMAGE:$VERSION" --version