-
Notifications
You must be signed in to change notification settings - Fork 0
1947 lines (1867 loc) · 115 KB
/
Copy pathdocker-sandboxes-images.yml
File metadata and controls
1947 lines (1867 loc) · 115 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
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Docker Sandboxes prebuilt images
on:
schedule:
- cron: '37 23 */7 * *'
- cron: '57 23 */7 * *'
push:
branches:
- main
paths:
- '.github/workflows/docker-sandboxes-images.yml'
- '.github/scripts/fetch-prebuilt-catalog.sh'
- 'templates/docker-sandboxes/**'
- 'scripts/docker-sandboxes/**'
- 'internal/prebuilt/**'
- 'cmd/epar-prebuilt-publisher/**'
pull_request:
branches:
- develop
- main
paths:
- '.github/workflows/docker-sandboxes-images.yml'
- '.github/scripts/fetch-prebuilt-catalog.sh'
- 'templates/docker-sandboxes/**'
- 'scripts/docker-sandboxes/**'
- 'internal/prebuilt/**'
- 'cmd/epar-prebuilt-publisher/**'
workflow_dispatch:
inputs:
profile:
description: 'Compatible v1 builds automatically advance this profile after its upstream and hosted gates pass.'
required: true
type: choice
options:
- act
- full
default: act
force_candidate:
description: 'Keep the result as a candidate even when compatible-v1 automatic promotion is eligible.'
required: true
type: boolean
default: false
rebuild_source_digest:
description: 'Optional exact active EPAR package digest whose signed upstream source/evidence will be reused. Evidence must still be <=10 days old for automatic alias advancement.'
required: false
type: string
default: ''
promote_candidate:
description: 'Promote one already-published candidate digest without rebuilding; requires protected environment approval and PROMOTE confirmation.'
required: true
type: boolean
default: false
candidate_digest:
description: 'Exact candidate package index digest (sha256:<64 lowercase hex>) for manual promotion.'
required: false
type: string
default: ''
candidate_catalog_reference:
description: 'Exact immutable signed candidate catalog reference used for protected promotion.'
required: false
type: string
default: ''
acceptance_evidence_json:
description: 'Reviewed JSON containing four run IDs, two receipt SHA-256 values, and the exact ephemeral runner name for every run.'
required: false
type: string
default: ''
promotion_confirmation:
description: 'Type PROMOTE exactly when promoting the supplied candidate digest.'
required: false
type: string
default: ''
permissions:
contents: read
packages: write
attestations: write
id-token: write
concurrency:
group: docker-sandboxes-prebuilt-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || 'publisher' }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
SOURCE_REPOSITORY: ghcr.io/catthehacker/ubuntu
PACKAGE_REPOSITORY: ghcr.io/solutionforest/ephemeral-action-runner/docker-sandboxes-template
CATALOG_ARTIFACT_TYPE: application/vnd.epar.prebuilt.catalog.v1
CATALOG_CONFIG_MEDIA_TYPE: application/vnd.epar.prebuilt.catalog.config.v1+json
CATALOG_LAYER_MEDIA_TYPE: application/vnd.epar.prebuilt.catalog.v1+json
RUNTIME_CONTRACT: docker-sandboxes-v1
TEMPLATE_SCHEMA: '2'
DOCKER_BUILD_RECORD_UPLOAD: 'false'
jobs:
validate:
name: Validate prebuilt publication contract without publishing
if: github.event_name == 'pull_request'
permissions:
contents: read
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out source
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Set up Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
cache: true
- name: Verify publisher and signed-evidence contracts
run: |
go test ./internal/prebuilt ./cmd/epar-prebuilt-publisher -count=1
bash -n .github/scripts/fetch-prebuilt-catalog.sh
- name: Validate committed Docker Sandboxes assets
shell: pwsh
run: |
scripts/docker-sandboxes/validate-assets.ps1 -Platform linux/amd64
scripts/docker-sandboxes/validate-assets.ps1 -Platform linux/arm64
scripts/docker-sandboxes/validate-prebuilt.ps1 -Platform linux/amd64
scripts/docker-sandboxes/validate-prebuilt.ps1 -Platform linux/arm64
upstream-gate:
name: Verify fresh upstream tag-producing workflow evidence
if: github.event_name != 'pull_request' && inputs.promote_candidate != true
permissions:
contents: read
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
profile: ${{ steps.gate.outputs.profile }}
eligible: ${{ steps.gate.outputs.eligible }}
evidence: ${{ steps.gate.outputs.evidence }}
reason: ${{ steps.gate.outputs.reason }}
steps:
- name: Check out source
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Set up Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
cache: true
- name: Evaluate upstream workflow, job, and step evidence
id: gate
shell: bash
env:
DISPATCH_PROFILE: ${{ inputs.profile }}
REBUILD_SOURCE_DIGEST: ${{ inputs.rebuild_source_digest }}
SCHEDULE_EXPRESSION: ${{ github.event.schedule }}
UPSTREAM_ACTIONS_READ_TOKEN: ${{ secrets.UPSTREAM_ACTIONS_READ_TOKEN || github.token }}
run: |
set -euo pipefail
profile="${DISPATCH_PROFILE:-act}"
if [[ "$GITHUB_EVENT_NAME" == schedule ]]; then
case "$SCHEDULE_EXPRESSION" in
'37 23 */7 * *') profile=full ;;
'57 23 */7 * *') profile=act ;;
*) echo "unsupported schedule expression: $SCHEDULE_EXPRESSION" >&2; exit 1 ;;
esac
fi
case "$profile" in
act|full) ;;
*) echo "unsupported profile: $profile" >&2; exit 1 ;;
esac
result="$RUNNER_TEMP/upstream-gate.json"
rebuild_source_digest="${REBUILD_SOURCE_DIGEST:-}"
if [[ -n "$rebuild_source_digest" ]]; then
[[ "$GITHUB_EVENT_NAME" == workflow_dispatch ]] || { echo 'rebuild_source_digest is valid only for workflow_dispatch' >&2; exit 1; }
[[ "$rebuild_source_digest" =~ ^sha256:[0-9a-f]{64}$ ]] || { echo 'rebuild_source_digest must be sha256:<64 lowercase hex>' >&2; exit 1; }
jq -n --arg reason 'explicit rebuild requested; signed active catalog source verification is deferred to resolve' '{eligible:true,reason:$reason,evidence:{}}' > "$result"
elif ! go run ./cmd/epar-prebuilt-publisher upstream-gate --profile "$profile" --output "$result"; then
jq -n --arg reason 'GitHub Actions metadata was unavailable or invalid; publication skipped without building or writing GHCR/catalog state' '{eligible:false,reason:$reason}' > "$result"
fi
eligible="$(jq -r 'if (.eligible | type) == "boolean" then (.eligible | tostring) else error("eligible must be boolean") end' "$result")"
reason="$(jq -er '.reason' "$result")"
evidence="$(jq -c '.evidence // {}' "$result")"
{
echo "profile=$profile"
echo "eligible=$eligible"
echo "evidence=$evidence"
echo "reason=$reason"
} >> "$GITHUB_OUTPUT"
{
echo '## Docker Sandboxes upstream publication gate'
echo
echo "- Profile: \`$profile\`"
echo "- Eligible: \`$eligible\`"
echo "- Reason: $reason"
if [[ "$eligible" == true ]]; then
if [[ -n "$rebuild_source_digest" ]]; then
echo "- Rebuild source package: \`$rebuild_source_digest\`"
echo '- Its signed active catalog entry, exact source descriptors, and historical upstream evidence will be verified before source access.'
else
echo "- Upstream run: \`$(jq -r '.evidence.repository + "/actions/runs/" + (.evidence.runId | tostring)' "$result")\`"
echo "- Completed: \`$(jq -r '.evidence.completedAt' "$result")\`"
fi
else
echo '- No source resolution, build, package push, catalog publication, or profile-tag movement was attempted.'
fi
} >> "$GITHUB_STEP_SUMMARY"
resolve:
name: Resolve immutable upstream and publication state
needs: upstream-gate
if: needs.upstream-gate.outputs.eligible == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
profile: ${{ steps.select.outputs.profile }}
source_tag: ${{ steps.select.outputs.source_tag }}
source_reference: ${{ steps.source.outputs.source_reference }}
source_index_digest: ${{ steps.source.outputs.index_digest }}
source_amd64_digest: ${{ steps.source.outputs.amd64_digest }}
source_arm64_digest: ${{ steps.source.outputs.arm64_digest }}
rebuild_source_digest: ${{ steps.rebuild.outputs.source_package_digest }}
recipe_digest: ${{ steps.recipe.outputs.recipe_digest }}
source_lock_digest: ${{ steps.recipe.outputs.source_lock_digest }}
tool_digest: ${{ steps.recipe.outputs.tool_digest }}
runner_version: ${{ steps.runner.outputs.version }}
runner_amd64_url: ${{ steps.runner.outputs.amd64_url }}
runner_amd64_digest: ${{ steps.runner.outputs.amd64_digest }}
runner_arm64_url: ${{ steps.runner.outputs.arm64_url }}
runner_arm64_digest: ${{ steps.runner.outputs.arm64_digest }}
catalog_manifest_digest: ${{ steps.catalog.outputs.catalog_manifest_digest }}
noop: ${{ steps.noop.outputs.noop }}
upstream_evidence: ${{ steps.rebuild.outputs.upstream_evidence }}
steps:
- name: Check out source
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Set up ORAS
uses: oras-project/setup-oras@1d808f7d7f6995cc68b7bf507bfe5c5446e1dc9d # v2.0.1
with:
version: 1.3.3
- name: Log in to GHCR for idempotent pointer reconciliation
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set up Go for signed catalog verification
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
cache: true
- name: Select profile and immutable source selector
id: select
shell: bash
env:
DISPATCH_PROFILE: ${{ inputs.profile }}
SCHEDULE_EXPRESSION: ${{ github.event.schedule }}
run: |
set -euo pipefail
profile="${DISPATCH_PROFILE:-act}"
if [[ "$GITHUB_EVENT_NAME" == schedule ]]; then
case "$SCHEDULE_EXPRESSION" in
'37 23 */7 * *') profile=full ;;
'57 23 */7 * *') profile=act ;;
*) echo "unsupported schedule expression: $SCHEDULE_EXPRESSION" >&2; exit 1 ;;
esac
fi
case "$profile" in
act|full) ;;
*) echo "unsupported profile: $profile" >&2; exit 1 ;;
esac
if [[ "$profile" == full && "$GITHUB_EVENT_NAME" != workflow_dispatch && "$GITHUB_EVENT_NAME" != schedule ]]; then
echo 'full may be selected only by its dedicated schedule or an explicit workflow dispatch' >&2
exit 1
fi
source_tag="${profile}-latest"
source_reference="${SOURCE_REPOSITORY}:${source_tag}"
{
echo "profile=$profile"
echo "source_tag=$source_tag"
echo "source_reference=$source_reference"
} >> "$GITHUB_OUTPUT"
- name: Verify explicit signed active rebuild source
id: rebuild
shell: bash
env:
PROFILE: ${{ steps.select.outputs.profile }}
REBUILD_SOURCE_DIGEST: ${{ inputs.rebuild_source_digest }}
FRESH_UPSTREAM_EVIDENCE: ${{ needs.upstream-gate.outputs.evidence }}
run: |
set -euo pipefail
requested="${REBUILD_SOURCE_DIGEST:-}"
if [[ -z "$requested" ]]; then
{
echo 'enabled=false'
echo 'source_package_digest='
echo 'catalog_manifest_digest='
echo "upstream_evidence=$FRESH_UPSTREAM_EVIDENCE"
} >> "$GITHUB_OUTPUT"
exit 0
fi
rebuild_dir="$RUNNER_TEMP/epar-rebuild"
mkdir -p "$rebuild_dir"
verified_catalog="$rebuild_dir/catalog-state.json"
verification="$rebuild_dir/catalog-verification.json"
selection="$rebuild_dir/source-selection.json"
go run ./cmd/epar-prebuilt-publisher verify-catalog \
--repository "$PACKAGE_REPOSITORY" \
--profile "$PROFILE" \
--ref refs/heads/main \
--allowed-events schedule,workflow_dispatch,push \
--output "$verified_catalog" > "$verification"
go run ./cmd/epar-prebuilt-publisher rebuild-source \
--catalog "$verified_catalog" \
--profile "$PROFILE" \
--package-digest "$requested" \
--output "$selection"
source_repository="$(jq -er '.source.repository' "$selection")"
source_reference="$(jq -er '.source.reference' "$selection")"
source_index_digest="$(jq -er '.source.indexDigest' "$selection")"
source_amd64_digest="$(jq -er '.source.platformDigests["linux/amd64"]' "$selection")"
source_arm64_digest="$(jq -er '.source.platformDigests["linux/arm64"]' "$selection")"
upstream_evidence="$(jq -c '.upstream' "$selection")"
catalog_manifest_digest="$(jq -er '.catalogManifestDigest' "$verification")"
[[ "$source_repository" == "$SOURCE_REPOSITORY" ]]
[[ "$source_reference" == "${SOURCE_REPOSITORY}@${source_index_digest}" ]]
[[ "$source_index_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
[[ "$source_amd64_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
[[ "$source_arm64_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
[[ "$catalog_manifest_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
{
echo 'enabled=true'
echo "source_package_digest=$requested"
echo "source_reference=$source_reference"
echo "source_index_digest=$source_index_digest"
echo "source_amd64_digest=$source_amd64_digest"
echo "source_arm64_digest=$source_arm64_digest"
echo "catalog_manifest_digest=$catalog_manifest_digest"
echo "upstream_evidence=$upstream_evidence"
} >> "$GITHUB_OUTPUT"
- name: Resolve OCI source index and platform descriptors
id: source
shell: bash
env:
SOURCE_REFERENCE: ${{ steps.select.outputs.source_reference }}
REBUILD_ENABLED: ${{ steps.rebuild.outputs.enabled }}
REBUILD_SOURCE_REFERENCE: ${{ steps.rebuild.outputs.source_reference }}
REBUILD_SOURCE_INDEX_DIGEST: ${{ steps.rebuild.outputs.source_index_digest }}
REBUILD_SOURCE_AMD64_DIGEST: ${{ steps.rebuild.outputs.source_amd64_digest }}
REBUILD_SOURCE_ARM64_DIGEST: ${{ steps.rebuild.outputs.source_arm64_digest }}
run: |
set -euo pipefail
mkdir -p "$RUNNER_TEMP/epar-source"
source_reference="$SOURCE_REFERENCE"
if [[ "$REBUILD_ENABLED" == true ]]; then
source_reference="$REBUILD_SOURCE_REFERENCE"
fi
oras manifest fetch "$source_reference" --format json > "$RUNNER_TEMP/epar-source/source.json"
index_digest="$(oras resolve "$source_reference")"
[[ "$index_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
platform_count="$(jq '[(.content.manifests // .manifests)[] | select(.platform.os == "linux" and (.platform.architecture == "amd64" or .platform.architecture == "arm64"))] | length' "$RUNNER_TEMP/epar-source/source.json")"
[[ "$platform_count" == 2 ]]
platform_names="$(jq -r '(.content.manifests // .manifests)[] | select(.platform.os == "linux" and (.platform.architecture == "amd64" or .platform.architecture == "arm64")) | .platform.architecture' "$RUNNER_TEMP/epar-source/source.json" | sort -u | paste -sd, -)"
[[ "$platform_names" == 'amd64,arm64' ]]
amd64_digest="$(jq -er '(.content.manifests // .manifests)[] | select(.platform.os == "linux" and .platform.architecture == "amd64") | .digest' "$RUNNER_TEMP/epar-source/source.json" | head -n 1)"
arm64_digest="$(jq -er '(.content.manifests // .manifests)[] | select(.platform.os == "linux" and .platform.architecture == "arm64") | .digest' "$RUNNER_TEMP/epar-source/source.json" | head -n 1)"
[[ "$amd64_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
[[ "$arm64_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
if [[ "$REBUILD_ENABLED" == true ]]; then
go run ./cmd/epar-prebuilt-publisher verify-rebuild-source \
--selection "$RUNNER_TEMP/epar-rebuild/source-selection.json" \
--reference "$source_reference" \
--index-digest "$index_digest" \
--amd64-digest "$amd64_digest" \
--arm64-digest "$arm64_digest"
[[ "$index_digest" == "$REBUILD_SOURCE_INDEX_DIGEST" ]]
[[ "$amd64_digest" == "$REBUILD_SOURCE_AMD64_DIGEST" ]]
[[ "$arm64_digest" == "$REBUILD_SOURCE_ARM64_DIGEST" ]]
fi
{
echo "source_reference=$source_reference"
echo "index_digest=$index_digest"
echo "amd64_digest=$amd64_digest"
echo "arm64_digest=$arm64_digest"
} >> "$GITHUB_OUTPUT"
- name: Resolve the exact Actions runner release assets
id: runner
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
release_json="$RUNNER_TEMP/actions-runner-release.json"
curl --fail --silent --show-error --retry 4 --retry-delay 2 \
-H 'Accept: application/vnd.github+json' \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H 'X-GitHub-Api-Version: 2022-11-28' \
https://api.github.com/repos/actions/runner/releases/latest > "$release_json"
version="$(jq -er '.tag_name | ltrimstr("v")' "$release_json")"
amd64_name="actions-runner-linux-x64-${version}.tar.gz"
arm64_name="actions-runner-linux-arm64-${version}.tar.gz"
amd64_url="$(jq -er --arg name "$amd64_name" '.assets[] | select(.name == $name) | .browser_download_url' "$release_json")"
arm64_url="$(jq -er --arg name "$arm64_name" '.assets[] | select(.name == $name) | .browser_download_url' "$release_json")"
amd64_digest="$(jq -er --arg name "$amd64_name" '.assets[] | select(.name == $name) | .digest' "$release_json")"
arm64_digest="$(jq -er --arg name "$arm64_name" '.assets[] | select(.name == $name) | .digest' "$release_json")"
[[ "$amd64_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
[[ "$arm64_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
{
echo "version=$version"
echo "amd64_url=$amd64_url"
echo "amd64_digest=$amd64_digest"
echo "arm64_url=$arm64_url"
echo "arm64_digest=$arm64_digest"
} >> "$GITHUB_OUTPUT"
- name: Compute immutable recipe and tool identities
id: recipe
shell: bash
run: |
set -euo pipefail
source_lock_digest="sha256:$(sha256sum templates/docker-sandboxes/sources.lock.json | awk '{print $1}')"
tool_digest="sha256:$(jq -cS '{dockerfileFrontend,sbomGenerator,goBuilder,emulation,tini}' templates/docker-sandboxes/sources.lock.json | sha256sum | awk '{print $1}')"
mapfile -t recipe_files < <(
git ls-files --cached -- \
'templates/docker-sandboxes/.dockerignore' \
'templates/docker-sandboxes/Dockerfile.prebuilt' \
'templates/docker-sandboxes/helpers.sha256' \
'templates/docker-sandboxes/prebuilt/**' \
'templates/docker-sandboxes/guest/**' \
'templates/docker-sandboxes/hook-launcher/main.go' \
'templates/docker-sandboxes/egress-bridge/main.go' \
'templates/docker-sandboxes/profiles/prebuilt.compatibility.json' | sort
)
((${#recipe_files[@]} > 0))
recipe_digest="sha256:$(printf '%s\n' "${recipe_files[@]}" | xargs sha256sum | sha256sum | awk '{print $1}')"
{
echo "source_lock_digest=$source_lock_digest"
echo "tool_digest=$tool_digest"
echo "recipe_digest=$recipe_digest"
} >> "$GITHUB_OUTPUT"
- name: Fetch current signed catalog state or initialize an empty ledger
id: catalog
shell: bash
env:
PROFILE: ${{ steps.select.outputs.profile }}
RUNNER_VERSION: ${{ steps.runner.outputs.version }}
RUNNER_AMD64_DIGEST: ${{ steps.runner.outputs.amd64_digest }}
RUNNER_ARM64_DIGEST: ${{ steps.runner.outputs.arm64_digest }}
SOURCE_INDEX_DIGEST: ${{ steps.source.outputs.index_digest }}
RECIPE_DIGEST: ${{ steps.recipe.outputs.recipe_digest }}
RECIPE_REVISION: ${{ github.sha }}
REBUILD_ENABLED: ${{ steps.rebuild.outputs.enabled }}
REBUILD_CATALOG_MANIFEST: ${{ steps.rebuild.outputs.catalog_manifest_digest }}
run: |
set -euo pipefail
catalog_dir="$RUNNER_TEMP/epar-catalog"
mkdir -p "$catalog_dir"
if [[ "$REBUILD_ENABLED" == true ]]; then
[[ "$REBUILD_CATALOG_MANIFEST" =~ ^sha256:[0-9a-f]{64}$ ]]
cp "$RUNNER_TEMP/epar-rebuild/catalog-state.json" "$catalog_dir/catalog-state.json"
echo "catalog_manifest_digest=$REBUILD_CATALOG_MANIFEST" >> "$GITHUB_OUTPUT"
else
catalog_reference="${PACKAGE_REPOSITORY}:catalog-v1"
catalog_error="$catalog_dir/catalog-fetch.error"
if catalog_digest="$(oras resolve "$catalog_reference" 2>"$catalog_error")"; then
[[ "$catalog_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
go run ./cmd/epar-prebuilt-publisher verify-catalog --repository "$PACKAGE_REPOSITORY" --profile act --reference "${PACKAGE_REPOSITORY}@${catalog_digest}" --ref refs/heads/main --allowed-events schedule,workflow_dispatch,push --output "$catalog_dir/catalog-state.json"
echo "catalog_manifest_digest=$catalog_digest" >> "$GITHUB_OUTPUT"
else
if ! grep -Eqi 'manifest unknown|not found|404' "$catalog_error"; then
cat "$catalog_error" >&2
exit 1
fi
cat > "$catalog_dir/catalog-state.json" <<'JSON'
{
"schemaVersion": 1,
"artifactKind": "docker-sandboxes-template",
"packageRepository": "ghcr.io/solutionforest/ephemeral-action-runner/docker-sandboxes-template",
"policies": {
"act": {"enabled": true, "wizardDefault": false, "autoAdvance": true},
"full": {"enabled": true, "wizardDefault": true, "autoAdvance": true}
},
"entries": [],
"aliases": {},
"transitions": []
}
JSON
echo 'catalog_manifest_digest=' >> "$GITHUB_OUTPUT"
fi
fi
jq '.policies.act = {enabled:true,wizardDefault:false,autoAdvance:true} | .policies.full = {enabled:true,wizardDefault:true,autoAdvance:true}' "$catalog_dir/catalog-state.json" > "$catalog_dir/catalog-state.tmp"
mv "$catalog_dir/catalog-state.tmp" "$catalog_dir/catalog-state.json"
jq -e . "$catalog_dir/catalog-state.json" >/dev/null
- name: Reconcile an interrupted catalog-first alias promotion
if: github.ref == 'refs/heads/main'
shell: bash
env:
PROFILE: ${{ steps.select.outputs.profile }}
EXPECTED_CATALOG_MANIFEST: ${{ steps.catalog.outputs.catalog_manifest_digest }}
run: |
set -euo pipefail
catalog="$RUNNER_TEMP/epar-catalog/catalog-state.json"
expected_catalog_manifest="${EXPECTED_CATALOG_MANIFEST:-}"
current_catalog_manifest=''
catalog_cas_error="$RUNNER_TEMP/epar-catalog/catalog-reconcile-cas.error"
if current_catalog_manifest="$(oras resolve "${PACKAGE_REPOSITORY}:catalog-v1" 2>"$catalog_cas_error")"; then
[[ "$current_catalog_manifest" =~ ^sha256:[0-9a-f]{64}$ ]]
else
if ! grep -Eqi 'manifest unknown|not found|404' "$catalog_cas_error"; then
cat "$catalog_cas_error" >&2
exit 1
fi
current_catalog_manifest=''
fi
[[ "$current_catalog_manifest" == "$expected_catalog_manifest" ]] || {
echo "catalog-v1 changed while preparing alias reconciliation (expected ${expected_catalog_manifest:-missing}, observed ${current_catalog_manifest:-missing})" >&2
exit 1
}
alias_ref="${PACKAGE_REPOSITORY}:${PROFILE}-latest"
observed=''
alias_error="$RUNNER_TEMP/epar-catalog/alias-reconcile.error"
if observed="$(oras resolve "$alias_ref" 2>"$alias_error")"; then
[[ "$observed" =~ ^sha256:[0-9a-f]{64}$ ]]
elif ! grep -Eqi 'manifest unknown|not found|404' "$alias_error"; then
cat "$alias_error" >&2
exit 1
fi
plan="$RUNNER_TEMP/epar-catalog/alias-reconciliation.json"
go run ./cmd/epar-prebuilt-publisher reconcile-alias --catalog "$catalog" --profile "$PROFILE" --observed-digest "$observed" --output "$plan"
if [[ "$(jq -r '.needsRepair' "$plan")" == true ]]; then
target="$(jq -er '.targetDigest' "$plan")"
[[ "$(oras resolve "${PACKAGE_REPOSITORY}@${target}")" == "$target" ]]
alias_cas_error="$RUNNER_TEMP/epar-catalog/alias-reconcile-cas.error"
current_alias_digest=''
if current_alias_digest="$(oras resolve "$alias_ref" 2>"$alias_cas_error")"; then
[[ "$current_alias_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
else
if ! grep -Eqi 'manifest unknown|not found|404' "$alias_cas_error"; then
cat "$alias_cas_error" >&2
exit 1
fi
current_alias_digest=''
fi
[[ "$current_alias_digest" == "$observed" ]] || {
echo "${PROFILE}-latest changed while preparing alias reconciliation (expected ${observed:-missing}, observed ${current_alias_digest:-missing})" >&2
exit 1
}
oras tag "${PACKAGE_REPOSITORY}@${target}" "${PROFILE}-latest"
[[ "$(oras resolve "$alias_ref")" == "$target" ]]
echo "Recovered interrupted ${PROFILE} alias promotion to ${target}." >> "$GITHUB_STEP_SUMMARY"
fi
- name: Determine whether the immutable tuple is already active
id: noop
shell: bash
env:
PROFILE: ${{ steps.select.outputs.profile }}
SOURCE_INDEX_DIGEST: ${{ steps.source.outputs.index_digest }}
SOURCE_AMD64_DIGEST: ${{ steps.source.outputs.amd64_digest }}
SOURCE_ARM64_DIGEST: ${{ steps.source.outputs.arm64_digest }}
RECIPE_DIGEST: ${{ steps.recipe.outputs.recipe_digest }}
RECIPE_REVISION: ${{ github.sha }}
SOURCE_LOCK_DIGEST: ${{ steps.recipe.outputs.source_lock_digest }}
TOOL_DIGEST: ${{ steps.recipe.outputs.tool_digest }}
RUNNER_VERSION: ${{ steps.runner.outputs.version }}
RUNNER_AMD64_DIGEST: ${{ steps.runner.outputs.amd64_digest }}
RUNNER_ARM64_DIGEST: ${{ steps.runner.outputs.arm64_digest }}
FORCE_CANDIDATE: ${{ inputs.force_candidate }}
run: |
set -euo pipefail
catalog="$RUNNER_TEMP/epar-catalog/catalog-state.json"
matching_entries="$RUNNER_TEMP/epar-catalog/matching-entries.json"
matching_entry="$RUNNER_TEMP/epar-catalog/matching-entry.json"
noop=false
if [[ "$FORCE_CANDIDATE" != true ]]; then
# Only an active entry can suppress a build. A matching candidate
# must be re-evaluated so a later fresh upstream gate can promote it.
jq -c --arg profile "$PROFILE" --arg source "$SOURCE_INDEX_DIGEST" \
--arg sourceAmd64 "$SOURCE_AMD64_DIGEST" --arg sourceArm64 "$SOURCE_ARM64_DIGEST" \
--arg recipe "$RECIPE_DIGEST" --arg revision "$RECIPE_REVISION" --arg sourceLock "$SOURCE_LOCK_DIGEST" --arg tool "$TOOL_DIGEST" \
--arg runtime "$RUNTIME_CONTRACT" --arg schema "$TEMPLATE_SCHEMA" --arg runner "$RUNNER_VERSION" \
--arg amd64 "$RUNNER_AMD64_DIGEST" --arg arm64 "$RUNNER_ARM64_DIGEST" \
'. as $catalog | [
$catalog.entries[] as $entry
| (([$catalog.transitions[]? | select(.packageIndexDigest == $entry.packageIndexDigest) | .toStatus] | last) // $entry.status) as $effectiveStatus
| select(
$effectiveStatus == "active"
and $entry.profile == $profile
and $entry.source.indexDigest == $source
and $entry.source.platformDigests["linux/amd64"] == $sourceAmd64
and $entry.source.platformDigests["linux/arm64"] == $sourceArm64
and $entry.recipe.digest == $recipe
and $entry.recipe.recipeRevision == $revision
and $entry.recipe.sourceLockDigest == $sourceLock
and $entry.recipe.toolDigest == $tool
and $entry.recipe.runtimeContract == $runtime
and ($entry.recipe.templateSchema | tostring) == $schema
and $entry.runner.version == $runner
and $entry.runner.assetDigests["linux/amd64"] == $amd64
and $entry.runner.assetDigests["linux/arm64"] == $arm64
and $entry.gates.sourceResolved == true
and $entry.gates.sourceRechecked == true
and $entry.gates.buildSucceeded == true
and $entry.gates.platformsValidated == true
and $entry.gates.provenanceGenerated == true
and $entry.gates.sbomGenerated == true
and $entry.gates.attestationVerified == true
and ($effectiveStatus != "active" or $catalog.aliases[$profile].packageIndexDigest == $entry.packageIndexDigest)
)
| $entry
]' "$catalog" > "$matching_entries"
match_count="$(jq 'length' "$matching_entries")"
case "$match_count" in
0)
echo 'No complete matching catalog entry; the hosted build will proceed.'
;;
1)
jq -e '.[0]' "$matching_entries" > "$matching_entry"
package_reference="$(jq -er '.packageReference' "$matching_entry")"
[[ "$package_reference" == "${PACKAGE_REPOSITORY}@sha256:"* ]]
# Verify the immutable package and its signed evidence before
# suppressing work. This is metadata-only and does not pull
# image layers. A failed verification is fail-closed.
go run ./cmd/epar-prebuilt-publisher verify-package \
--reference "$package_reference" \
--entry "$matching_entry" \
--repository "$PACKAGE_REPOSITORY" \
--ref refs/heads/main \
--allowed-events schedule,workflow_dispatch,push \
> "$RUNNER_TEMP/epar-catalog/package-verification.json"
noop=true
echo "Verified immutable package metadata for $package_reference; skipping hosted builds."
;;
*)
echo "Catalog contains $match_count complete matching entries; refusing an ambiguous no-op." >&2
exit 1
;;
esac
fi
echo "noop=$noop" >> "$GITHUB_OUTPUT"
- name: Preserve catalog state for the publication job
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: epar-prebuilt-catalog-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/epar-catalog/catalog-state.json
if-no-files-found: error
retention-days: 14
build:
name: Build immutable ${{ matrix.platform }} package layer
needs: resolve
if: needs.resolve.outputs.noop != 'true'
runs-on: ${{ matrix.runner }}
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
slug: amd64
runner: ubuntu-latest
source_digest: ${{ needs.resolve.outputs.source_amd64_digest }}
runner_url: ${{ needs.resolve.outputs.runner_amd64_url }}
runner_digest: ${{ needs.resolve.outputs.runner_amd64_digest }}
- platform: linux/arm64
slug: arm64
runner: ubuntu-24.04-arm
source_digest: ${{ needs.resolve.outputs.source_arm64_digest }}
runner_url: ${{ needs.resolve.outputs.runner_arm64_url }}
runner_digest: ${{ needs.resolve.outputs.runner_arm64_digest }}
steps:
- name: Check out source
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Prepare hosted capacity for the Full profile
if: needs.resolve.outputs.profile == 'full'
shell: bash
run: |
set -euo pipefail
echo 'Full requires substantially more unpacked Docker storage than the standard 14 GB hosted-runner allowance.'
df -h /
free -h
sudo rm -rf \
/usr/local/lib/android \
/usr/share/dotnet \
/opt/ghc \
/usr/local/.ghcup \
/opt/hostedtoolcache/CodeQL
docker system prune --all --force --volumes
available_kib="$(df --output=avail / | tail -n 1 | tr -d '[:space:]')"
minimum_kib="$((40 * 1024 * 1024))"
if (( available_kib < minimum_kib )); then
echo "Full publication requires at least 40 GiB free before its 8 GiB swap allocation; observed $((available_kib / 1024 / 1024)) GiB" >&2
exit 1
fi
swap_path=/mnt/epar-full-build.swap
sudo fallocate -l 8G "$swap_path"
sudo chmod 0600 "$swap_path"
sudo mkswap "$swap_path"
sudo swapon "$swap_path"
df -h /
free -h
- name: Log in to GHCR
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set up QEMU for the declared foreign platform
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4
with:
image: docker.io/tonistiigi/binfmt@sha256:400a4873b838d1b89194d982c45e5fb3cda4593fbfd7e08a02e76b03b21166f0
platforms: all
- name: Set up Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
with:
buildkitd-config-inline: |
[worker.oci]
max-parallelism = 1
- name: Fetch immutable runner, Tini, and emulation license inputs
id: inputs
shell: bash
env:
RUNNER_URL: ${{ matrix.runner_url }}
RUNNER_DIGEST: ${{ matrix.runner_digest }}
PLATFORM: ${{ matrix.platform }}
run: |
set -euo pipefail
mkdir -p templates/docker-sandboxes/inputs/emulation-licenses
curl --fail --location --proto '=https' --proto-redir '=https' --silent --show-error --retry 4 --retry-delay 2 "$RUNNER_URL" -o templates/docker-sandboxes/inputs/actions-runner.tar.gz
echo "${RUNNER_DIGEST#sha256:} templates/docker-sandboxes/inputs/actions-runner.tar.gz" | sha256sum --check -
tini_url="$(jq -er --arg platform "$PLATFORM" '.platforms[$platform].tini.url' templates/docker-sandboxes/sources.lock.json)"
tini_digest="$(jq -er --arg platform "$PLATFORM" '.platforms[$platform].tini.sha256' templates/docker-sandboxes/sources.lock.json)"
curl --fail --location --proto '=https' --proto-redir '=https' --silent --show-error --retry 4 --retry-delay 2 "$tini_url" -o templates/docker-sandboxes/inputs/tini
echo "${tini_digest#sha256:} templates/docker-sandboxes/inputs/tini" | sha256sum --check -
chmod 0555 templates/docker-sandboxes/inputs/tini
licenses=(
'tonistiigi-binfmt-MIT.txt|https://raw.githubusercontent.com/tonistiigi/binfmt/e29e7d72c9672c8c8bf846655ab149b50e1a62bd/LICENSE|bba3332a1e2ec03031b587452cd9254bd7ab6ec701aef20b12e642f47f423dd6'
'qemu-COPYING.txt|https://raw.githubusercontent.com/qemu/qemu/v10.2.3/COPYING|dd3ce02338c3a48abb6ba59b48809f7108a8bd242cb0cc8be90daafa30707c28'
)
for item in "${licenses[@]}"; do
IFS='|' read -r name url digest <<< "$item"
curl --fail --silent --show-error --retry 4 --retry-delay 2 "$url" -o "templates/docker-sandboxes/inputs/emulation-licenses/$name"
echo "$digest templates/docker-sandboxes/inputs/emulation-licenses/$name" | sha256sum --check -
done
go_builder="$(jq -er --arg platform "$PLATFORM" '.platforms[$platform].goBuilderReference' templates/docker-sandboxes/sources.lock.json)"
binfmt="$(jq -er --arg platform "$PLATFORM" '.emulation.platforms[$platform].sourceReference' templates/docker-sandboxes/sources.lock.json)"
tini_sha="$(jq -er --arg platform "$PLATFORM" '.platforms[$platform].tini.sha256' templates/docker-sandboxes/sources.lock.json)"
hook_sha="$(jq -er '.hookLauncher.sha256' templates/docker-sandboxes/sources.lock.json)"
egress_sha="$(jq -er '.egressBridge.sha256' templates/docker-sandboxes/sources.lock.json)"
echo "go_builder=$go_builder" >> "$GITHUB_OUTPUT"
echo "binfmt=$binfmt" >> "$GITHUB_OUTPUT"
echo "tini_sha=$tini_sha" >> "$GITHUB_OUTPUT"
echo "hook_sha=$hook_sha" >> "$GITHUB_OUTPUT"
echo "egress_sha=$egress_sha" >> "$GITHUB_OUTPUT"
- name: Build and push platform candidate
id: push
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
context: templates/docker-sandboxes
file: templates/docker-sandboxes/Dockerfile.prebuilt
target: runner-template
platforms: ${{ matrix.platform }}
push: true
pull: true
tags: ${{ env.PACKAGE_REPOSITORY }}:candidate-${{ needs.resolve.outputs.profile }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.slug }}
build-args: |
TEMPLATE_PLATFORM=${{ matrix.platform }}
SOURCE_IMAGE=${{ env.SOURCE_REPOSITORY }}@${{ matrix.source_digest }}
SOURCE_PROFILE=${{ needs.resolve.outputs.profile }}
SOURCE_INDEX_DIGEST=${{ needs.resolve.outputs.source_index_digest }}
SOURCE_MANIFEST_DIGEST=${{ matrix.source_digest }}
GO_BUILDER_IMAGE=${{ steps.inputs.outputs.go_builder }}
BINFMT_IMAGE=${{ steps.inputs.outputs.binfmt }}
EPAR_RECIPE_DIGEST=${{ needs.resolve.outputs.recipe_digest }}
EPAR_RUNTIME_CONTRACT=${{ env.RUNTIME_CONTRACT }}
TEMPLATE_VERSION=${{ github.sha }}-${{ matrix.slug }}
COMPATIBILITY_FILE=prebuilt.compatibility.json
HOOK_LAUNCHER_SHA256=${{ steps.inputs.outputs.hook_sha }}
EGRESS_BRIDGE_SHA256=${{ steps.inputs.outputs.egress_sha }}
TINI_SHA256=${{ steps.inputs.outputs.tini_sha }}
RUNNER_SELECTOR=latest
RUNNER_VERSION=${{ needs.resolve.outputs.runner_version }}
RUNNER_ASSET_DIGEST=${{ matrix.runner_digest }}
ACTIONS_RUNNER_VERSION=${{ needs.resolve.outputs.runner_version }}
ACTIONS_RUNNER_SHA256=${{ matrix.runner_digest }}
# The signed SLSA and SPDX referrers are generated for the completed
# multi-platform index below. Disabling BuildKit's additional
# per-platform attestations avoids duplicate evidence indexes while
# retaining the exact runnable platform manifests in that index.
provenance: false
sbom: false
- name: Record platform digest and runner tuple
shell: bash
env:
PLATFORM: ${{ matrix.platform }}
PLATFORM_SLUG: ${{ matrix.slug }}
CANDIDATE_DESCRIPTOR_DIGEST: ${{ steps.push.outputs.digest }}
PACKAGE_REPOSITORY: ${{ env.PACKAGE_REPOSITORY }}
RUNNER_VERSION: ${{ needs.resolve.outputs.runner_version }}
RUNNER_DIGEST: ${{ matrix.runner_digest }}
run: |
set -euo pipefail
[[ "$CANDIDATE_DESCRIPTOR_DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]
platform_candidate_ref="${PACKAGE_REPOSITORY}@${CANDIDATE_DESCRIPTOR_DIGEST}"
docker buildx imagetools inspect "$platform_candidate_ref" --raw > "$RUNNER_TEMP/platform-candidate-descriptor.json"
media_type="$(jq -er '.mediaType' "$RUNNER_TEMP/platform-candidate-descriptor.json")"
case "$media_type" in
application/vnd.oci.image.manifest.v1+json|application/vnd.docker.distribution.manifest.v2+json)
package_manifest_digest="$CANDIDATE_DESCRIPTOR_DIGEST"
;;
application/vnd.oci.image.index.v1+json|application/vnd.docker.distribution.manifest.list.v2+json)
architecture="${PLATFORM#linux/}"
package_manifest_digest="$(jq -er --arg architecture "$architecture" \
'[.manifests[] | select(.platform.os == "linux" and .platform.architecture == $architecture)] | if length == 1 then .[0].digest else error("expected exactly one runnable platform manifest") end' \
"$RUNNER_TEMP/platform-candidate-descriptor.json")"
;;
*)
echo "unsupported platform candidate media type: $media_type" >&2
exit 1
;;
esac
[[ "$package_manifest_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
jq -n --arg platform "$PLATFORM" --arg slug "$PLATFORM_SLUG" --arg digest "$package_manifest_digest" --arg candidateDescriptorDigest "$CANDIDATE_DESCRIPTOR_DIGEST" --arg runner "$RUNNER_VERSION" --arg runnerDigest "$RUNNER_DIGEST" \
'{platform:$platform,slug:$slug,packageManifestDigest:$digest,candidateDescriptorDigest:$candidateDescriptorDigest,runnerVersion:$runner,runnerAssetDigest:$runnerDigest}' > "$RUNNER_TEMP/platform-result.json"
- name: Upload platform digest
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: epar-prebuilt-platform-${{ needs.resolve.outputs.profile }}-${{ matrix.slug }}-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/platform-result.json
if-no-files-found: error
retention-days: 14
publish:
name: Verify, attest, and publish catalog state
needs:
- resolve
- build
if: needs.resolve.outputs.noop != 'true'
runs-on: ubuntu-latest
timeout-minutes: 120
outputs:
profile: ${{ needs.resolve.outputs.profile }}
index_digest: ${{ steps.index.outputs.index_digest }}
package_ref: ${{ steps.index.outputs.package_ref }}
source_rechecked: ${{ steps.index.outputs.source_rechecked }}
publication_artifact: epar-prebuilt-publication-${{ needs.resolve.outputs.profile }}-${{ github.run_id }}-${{ github.run_attempt }}
steps:
- name: Check out source
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Set up Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
cache: true
- name: Set up ORAS
uses: oras-project/setup-oras@1d808f7d7f6995cc68b7bf507bfe5c5446e1dc9d # v2.0.1
with:
version: 1.3.3
- name: Log in to GHCR
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set up QEMU and Buildx for readback
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4
with:
image: docker.io/tonistiigi/binfmt@sha256:400a4873b838d1b89194d982c45e5fb3cda4593fbfd7e08a02e76b03b21166f0
platforms: all
- name: Set up Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: Download catalog and platform results
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
pattern: epar-prebuilt-*
path: ${{ runner.temp }}/epar-artifacts
merge-multiple: false
- name: Merge platform manifests and verify immutable index
id: index
shell: bash
env:
PROFILE: ${{ needs.resolve.outputs.profile }}
SOURCE_REFERENCE: ${{ needs.resolve.outputs.source_reference }}
SOURCE_INDEX_DIGEST: ${{ needs.resolve.outputs.source_index_digest }}
run: |
set -euo pipefail
amd64_result="$(find "$RUNNER_TEMP/epar-artifacts" -path '*amd64*/platform-result.json' -print -quit)"
arm64_result="$(find "$RUNNER_TEMP/epar-artifacts" -path '*arm64*/platform-result.json' -print -quit)"
[[ -f "$amd64_result" && -f "$arm64_result" ]]
amd64_digest="$(jq -er '.packageManifestDigest' "$amd64_result")"
arm64_digest="$(jq -er '.packageManifestDigest' "$arm64_result")"
[[ "$amd64_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
[[ "$arm64_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
staging_ref="${PACKAGE_REPOSITORY}:candidate-${PROFILE}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
docker buildx imagetools create --tag "$staging_ref" \
"${PACKAGE_REPOSITORY}@${amd64_digest}" \
"${PACKAGE_REPOSITORY}@${arm64_digest}"
index_digest="$(oras resolve "$staging_ref")"
[[ "$index_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
oras manifest fetch "$staging_ref" --format json > "$RUNNER_TEMP/epar-index.json"
jq -e --arg amd64 "$amd64_digest" --arg arm64 "$arm64_digest" \
'[(.content.manifests // .manifests)[]] as $manifests | ($manifests | length) == 2 and ($manifests | map(select(.platform.os == "linux" and (.platform.architecture == "amd64" or .platform.architecture == "arm64"))) | length) == 2 and ($manifests | map(.platform.architecture) | sort == ["amd64","arm64"]) and ($manifests | map(.digest) | sort == ([$amd64,$arm64] | sort))' "$RUNNER_TEMP/epar-index.json" >/dev/null
current_source_digest="$(oras resolve "$SOURCE_REFERENCE")"
[[ "$current_source_digest" =~ ^sha256:[0-9a-f]{64}$ ]]
source_rechecked=true
if [[ "$current_source_digest" != "$SOURCE_INDEX_DIGEST" ]]; then
source_rechecked=false
echo "upstream source moved from $SOURCE_INDEX_DIGEST to $current_source_digest; keeping candidate only" >&2
fi
package_tag="${PROFILE}-latest-pkg-${index_digest#sha256:}"
package_ref="${PACKAGE_REPOSITORY}@${index_digest}"
immutable_tag_ref="${PACKAGE_REPOSITORY}:${package_tag}"
tag_error="$RUNNER_TEMP/epar-package-tag-resolve.error"
if existing_digest="$(oras resolve "$immutable_tag_ref" 2>"$tag_error")"; then
[[ "$existing_digest" == "$index_digest" ]]
else
if ! grep -Eqi 'manifest unknown|not found|404' "$tag_error"; then
cat "$tag_error" >&2
exit 1
fi
docker buildx imagetools create --tag "$immutable_tag_ref" "$staging_ref"
[[ "$(oras resolve "$immutable_tag_ref")" == "$index_digest" ]]
fi
{
echo "index_digest=$index_digest"
echo "package_tag=$package_tag"
echo "package_ref=$package_ref"
echo "immutable_tag_ref=$immutable_tag_ref"
echo "amd64_digest=$amd64_digest"
echo "arm64_digest=$arm64_digest"
echo "source_rechecked=$source_rechecked"
echo "source_observed_digest=$current_source_digest"
} >> "$GITHUB_OUTPUT"
- name: Run hosted two-platform template smoke checks
shell: bash
env:
PACKAGE_AMD64_DIGEST: ${{ steps.index.outputs.amd64_digest }}
PACKAGE_ARM64_DIGEST: ${{ steps.index.outputs.arm64_digest }}
run: |
set -euo pipefail
for platform_and_digest in "linux/amd64|$PACKAGE_AMD64_DIGEST" "linux/arm64|$PACKAGE_ARM64_DIGEST"; do
IFS='|' read -r platform platform_digest <<< "$platform_and_digest"
platform_ref="${PACKAGE_REPOSITORY}@${platform_digest}"
docker pull --platform "$platform" "$platform_ref" >/dev/null
docker run --rm --platform "$platform" --entrypoint /bin/bash "$platform_ref" -lc '
set -euo pipefail
test -x /opt/actions-runner/bin/Runner.Listener
test -x /usr/local/bin/tini
test -x /opt/epar/verify-template.sh
/opt/actions-runner/bin/Runner.Listener --version >/dev/null
/usr/local/bin/tini --version 2>&1 | grep -qi tini
docker --version >/dev/null
dockerd --version >/dev/null
'
done
- name: Prepare EPAR SLSA predicate and SPDX SBOM
id: evidence
shell: bash
env:
SOURCE_INDEX_DIGEST: ${{ needs.resolve.outputs.source_index_digest }}
SOURCE_AMD64_DIGEST: ${{ needs.resolve.outputs.source_amd64_digest }}
SOURCE_ARM64_DIGEST: ${{ needs.resolve.outputs.source_arm64_digest }}
PACKAGE_INDEX_DIGEST: ${{ steps.index.outputs.index_digest }}
PACKAGE_AMD64_DIGEST: ${{ steps.index.outputs.amd64_digest }}
PACKAGE_ARM64_DIGEST: ${{ steps.index.outputs.arm64_digest }}
RECIPE_DIGEST: ${{ needs.resolve.outputs.recipe_digest }}
RECIPE_REVISION: ${{ github.sha }}
TOOL_DIGEST: ${{ needs.resolve.outputs.tool_digest }}
RUNNER_VERSION: ${{ needs.resolve.outputs.runner_version }}
RUNNER_AMD64_DIGEST: ${{ needs.resolve.outputs.runner_amd64_digest }}
RUNNER_ARM64_DIGEST: ${{ needs.resolve.outputs.runner_arm64_digest }}
REPOSITORY_ID: ${{ github.repository_id }}
REPOSITORY_OWNER_ID: ${{ github.repository_owner_id }}
run: |
set -euo pipefail