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