1+ ---
2+ name : Docker Image
3+
4+ on :
5+ push :
6+ tags : [ '*.*.*' ]
7+
8+ env :
9+ REGISTRY_IMAGE : ghcr.io/rgrizzell/circuitpython
10+
11+ jobs :
12+ build :
13+ runs-on : ubuntu-latest
14+ strategy :
15+ fail-fast : false
16+ matrix :
17+ platform :
18+ - linux/amd64
19+ - linux/arm64
20+ steps :
21+ - name : Prepare
22+ run : |
23+ platform=${{ matrix.platform }}
24+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
25+
26+ - name : Checkout
27+ uses : actions/checkout@v4
28+
29+ - name : Docker meta
30+ id : meta
31+ uses : docker/metadata-action@v5
32+ with :
33+ images : ${{ env.REGISTRY_IMAGE }}
34+
35+ - name : Set up QEMU
36+ uses : docker/setup-qemu-action@v3
37+
38+ - name : Set up Docker Buildx
39+ uses : docker/setup-buildx-action@v3
40+
41+ - name : Login to GitHub Container Registry
42+ uses : docker/login-action@v3
43+ with :
44+ registry : ghcr.io
45+ username : ${{ github.repository_owner }}
46+ password : ${{ secrets.GITHUB_TOKEN }}
47+
48+ - name : Build and push by digest
49+ id : build
50+ uses : docker/build-push-action@v5
51+ with :
52+ context : .
53+ platforms : ${{ matrix.platform }}
54+ labels : ${{ steps.meta.outputs.labels }}
55+ outputs : type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
56+
57+ - name : Export digest
58+ run : |
59+ mkdir -p /tmp/digests
60+ digest="${{ steps.build.outputs.digest }}"
61+ touch "/tmp/digests/${digest#sha256:}"
62+
63+ - name : Upload digest
64+ uses : actions/upload-artifact@v4
65+ with :
66+ name : digests-${{ env.PLATFORM_PAIR }}
67+ path : /tmp/digests/*
68+ if-no-files-found : error
69+ retention-days : 1
70+
71+ merge :
72+ runs-on : ubuntu-latest
73+ needs :
74+ - build
75+ steps :
76+ - name : Download digests
77+ uses : actions/download-artifact@v4
78+ with :
79+ path : /tmp/digests
80+ pattern : digests-*
81+ merge-multiple : true
82+
83+ - name : Set up Docker Buildx
84+ uses : docker/setup-buildx-action@v3
85+
86+ - name : Docker meta
87+ id : meta
88+ uses : docker/metadata-action@v5
89+ with :
90+ images : ${{ env.REGISTRY_IMAGE }}
91+
92+ - name : Login to GitHub Container Registry
93+ uses : docker/login-action@v3
94+ with :
95+ registry : ghcr.io
96+ username : ${{ github.repository_owner }}
97+ password : ${{ secrets.GITHUB_TOKEN }}
98+
99+ - name : Create manifest list and push
100+ working-directory : /tmp/digests
101+ run : |
102+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
103+ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
104+
105+ - name : Inspect image
106+ run : |
107+ docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
0 commit comments