@@ -33,10 +33,22 @@ jobs:
33
33
34
34
build-docker :
35
35
runs-on : ubuntu-latest
36
+ strategy :
37
+ matrix :
38
+ platform :
39
+ - linux/arm64
40
+ - linux/amd64
36
41
37
42
steps :
38
43
- name : Checkout code
39
- uses : actions/checkout@v2
44
+ uses : actions/checkout@v3
45
+
46
+ - name : Set up QEMU
47
+ uses : docker/setup-qemu-action@v2
48
+ if : ${{ matrix.platform != 'linux/amd64' }}
49
+
50
+ - name : Set up Docker Buildx
51
+ uses : docker/setup-buildx-action@v2
40
52
41
53
- name : Acquire Docker image metadata
42
54
id : metadata
@@ -49,16 +61,59 @@ jobs:
49
61
with :
50
62
username : ${{ secrets.DOCKERHUB_USERNAME }}
51
63
password : ${{ secrets.DOCKERHUB_TOKEN }}
52
-
53
- - name : Install QEMU
54
- run : |
55
- sudo apt-get install -y qemu qemu-user-static binfmt-support
56
-
57
- - name : Build and push Docker image
58
- uses : docker/build-push-action@v3
64
+
65
+ - name : Build and push by digest
66
+ uses : docker/build-push-action@v4
67
+ id : build
59
68
with :
60
69
context : .
61
- platforms : linux/amd64,linux/arm64
62
- tags : ${{ steps.metadata.outputs.tags }}
63
70
labels : ${{ steps.metadata.outputs.labels }}
64
- push : true
71
+ platforms : ${{ matrix.platform }}
72
+ outputs : type=image,name=valeriansaliou/sonic,push-by-digest=true,name-canonical=true,push=true
73
+
74
+ - name : Export digests
75
+ run : |
76
+ mkdir -p /tmp/digests
77
+ digest="${{ steps.build.outputs.digest }}"
78
+ touch "/tmp/digests/${digest#sha256:}"
79
+
80
+ - name : Upload digests
81
+ uses : actions/upload-artifact@v3
82
+ with :
83
+ name : docker-digests
84
+ path : /tmp/digests/*
85
+ if-no-files-found : error
86
+ retention-days : 1
87
+
88
+ merge-docker :
89
+ runs-on : ubuntu-latest
90
+ needs :
91
+ - build-docker
92
+
93
+ steps :
94
+ - name : Download digests
95
+ uses : actions/download-artifact@v3
96
+ with :
97
+ name : docker-digests
98
+ path : /tmp/digests
99
+
100
+ - name : Set up Docker Buildx
101
+ uses : docker/setup-buildx-action@v2
102
+
103
+ - name : Login to Docker Hub
104
+ uses : docker/login-action@v2
105
+ with :
106
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
107
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
108
+
109
+ - name : Extract metadata (tags, labels) for Docker
110
+ id : meta
111
+ uses : docker/metadata-action@v4
112
+ with :
113
+ images : valeriansaliou/sonic
114
+
115
+ - name : Create manifest list and push
116
+ working-directory : /tmp/digests
117
+ run : |
118
+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
119
+ $(printf 'valeriansaliou/sonic@sha256:%s ' *)
0 commit comments