88 schedule :
99 - cron : " 0 2 * * *" # run at 2 AM UTC
1010
11+ env :
12+ REGISTRY_IMAGE : ghcr.io/drop-oss/drop
13+
1114jobs :
12- web :
13- name : Build Docker image
14- # self-hosted runner to speed things up
15- runs-on : [self-hosted, linux]
15+ build :
16+ strategy :
17+ fail-fast : false
18+ matrix :
19+ include :
20+ - platform : linux/amd64
21+ runner : ubuntu-latest
22+ - platform : linux/arm64
23+ runner : ubuntu-24.04-arm
24+ runs-on : ${{ matrix.runner }}
1625 permissions :
1726 packages : write
1827 contents : read
2635 ref : ${{ github.ref }}
2736 token : ${{ secrets.GITHUB_TOKEN }}
2837
38+ - name : Prepare
39+ run : |
40+ platform=${{ matrix.platform }}
41+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
42+
43+ - name : Docker meta
44+ id : meta
45+ uses : docker/metadata-action@v5
46+ with :
47+ images : ${{ env.REGISTRY_IMAGE }}
48+
49+ - name : Login to Docker Hub
50+ uses : docker/login-action@v3
51+ with :
52+ registry : ghcr.io
53+ username : ${{ github.actor }}
54+ password : ${{ secrets.GITHUB_TOKEN }}
55+
56+ - name : Set up QEMU
57+ uses : docker/setup-qemu-action@v3
58+
59+ - name : Set up Docker Buildx
60+ uses : docker/setup-buildx-action@v3
61+
2962 - name : Determine final version
3063 id : get_final_ver
3164 run : |
@@ -44,22 +77,58 @@ jobs:
4477 echo "Drop's release tag will be: $FINAL_VER"
4578 echo "final_ver=$FINAL_VER" >> $GITHUB_OUTPUT
4679
47- - name : Set up QEMU
48- uses : docker/setup-qemu-action@v3
80+ - name : Build and push by digest
81+ id : build
82+ uses : docker/build-push-action@v6
83+ with :
84+ platforms : ${{ matrix.platform }}
85+ labels : ${{ steps.meta.outputs.labels }}
86+ tags : ${{ env.REGISTRY_IMAGE }}
87+ outputs : type=image,push-by-digest=true,name-canonical=true,push=true
88+ provenance : mode=max
89+ sbom : true
90+ build-args : |
91+ BUILD_DROP_VERSION=${{ steps.get_final_ver.outputs.final_ver }}
92+ BUILD_GIT_REF=${{ github.sha }}
4993
50- - name : Set up Docker Buildx
51- id : buildx
52- uses : docker/setup-buildx-action@v3
94+ - name : Export digest
95+ run : |
96+ mkdir -p ${{ runner.temp }}/digests
97+ digest="${{ steps.build.outputs.digest }}"
98+ touch "${{ runner.temp }}/digests/${digest#sha256:}"
99+
100+ - name : Upload digest
101+ uses : actions/upload-artifact@v4
53102 with :
54- buildkitd-flags : --debug
103+ name : digests-${{ env.PLATFORM_PAIR }}
104+ path : ${{ runner.temp }}/digests/*
105+ if-no-files-found : error
106+ retention-days : 1
55107
56- - name : Log in to the Container registry
108+ merge :
109+ runs-on : ubuntu-latest
110+ needs :
111+ - build
112+ permissions :
113+ packages : write
114+ contents : read
115+ steps :
116+ - name : Download digests
117+ uses : actions/download-artifact@v4
118+ with :
119+ path : ${{ runner.temp }}/digests
120+ pattern : digests-*
121+ merge-multiple : true
122+
123+ - name : Login to Docker Hub
57124 uses : docker/login-action@v3
58125 with :
59126 registry : ghcr.io
60127 username : ${{ github.actor }}
61128 password : ${{ secrets.GITHUB_TOKEN }}
62129
130+ - name : Set up Docker Buildx
131+ uses : docker/setup-buildx-action@v3
63132 - name : Extract metadata (tags, labels) for Docker
64133 id : meta
65134 uses : docker/metadata-action@v5
@@ -78,33 +147,12 @@ jobs:
78147 # set latest tag for stable releases
79148 type=raw,value=latest,enable=${{ github.event_name == 'release' && github.event.release.prerelease == false }}
80149
81- - name : Cache
82- uses : actions/cache@v4
83- id : cache
84- with :
85- path : cache-mount
86- key : cache-mount-${{ hashFiles('Dockerfile') }}
87-
88- - name : Restore Docker cache mounts
89- uses : reproducible-containers/buildkit-cache-dance@v3
90- with :
91- builder : ${{ steps.setup-buildx.outputs.name }}
92- cache-dir : cache-mount
93- dockerfile : Dockerfile
94- skip-extraction : ${{ steps.cache.outputs.cache-hit }}
150+ - name : Create manifest list and push
151+ working-directory : ${{ runner.temp }}/digests
152+ run : |
153+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
154+ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
95155
96- - name : Build and push image
97- id : build-and-push
98- uses : docker/build-push-action@v6
99- with :
100- context : .
101- push : true
102- provenance : mode=max
103- sbom : true
104- tags : ${{ steps.meta.outputs.tags }}
105- labels : ${{ steps.meta.outputs.labels }}
106- platforms : linux/amd64,linux/arm64
107- cache-from : type=gha
108- cache-to : type=gha,mode=max
109- build-args : |
110- BUILD_DROP_VERSION=${{ steps.get_final_ver.outputs.final_ver }}
156+ - name : Inspect image
157+ run : |
158+ docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
0 commit comments