Push Docker images to registries individually.
Because docker/build-push-action can't handle the case of pushing to multiple registries by digest.
Austin S. Hemmelgarn committed
Mar 5, 2024 at 10:03 UTC
935ffce11483dd06eb241fc6c76e548fd66ac03f
2 files changed
+21
-12
.github/scripts/gen-docker-build-output.py
deleted
-11
@@ -1,11 +0,0 @@
1
-#!/usr/bin/env python3
2
-
3
-import sys
4
-
5
-event = sys.argv[1]
6
-
7
-match event:
8
- case 'workflow_dispatch':
9
- print('type=image,push=true,push-by-digest=true,name-canonical=true')
10
- case _:
11
- print('type=docker')
.github/workflows/docker.yml
+21
-1
@@ -146,6 +146,7 @@ jobs:
146
- name: Docker Hub Login
147
id: docker-hub-login
148
if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch'
149
+ continue-on-error: true
150
uses: docker/login-action@v3
151
with:
152
username: ${{ secrets.DOCKER_HUB_USERNAME }}
@@ -153,6 +154,7 @@ jobs:
154
# - name: GitHub Container Registry Login
155
# id: ghcr-login
156
# if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch'
157
+# continue-on-error: true
158
# uses: docker/login-action@v3
159
# with:
160
# registry: ghcr.io
@@ -161,6 +163,7 @@ jobs:
163
- name: Quay.io Login
164
id: quay-login
165
if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch'
166
+ continue-on-error: true
167
uses: docker/login-action@v3
168
with:
169
registry: quay.io
@@ -173,12 +176,27 @@ jobs:
176
with:
177
platforms: ${{ matrix.platform }}
178
tags: ${{ needs.gen-tags.outputs.tags }}
179
+ load: true
180
build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
177
- outputs: ${{ steps.gen-config.outputs.output-config }}
181
- name: Test Image
182
id: test
183
if: needs.file-check.outputs.run == 'true' && matrix.platform == 'linux/amd64'
184
run: .github/scripts/docker-test.sh
185
+ - name: Push to Docker Hub
186
+ id: push-docker-hub
187
+ if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch' && steps.docker-hub-login.outcome == 'success'
188
+ continue-on-error: true
189
+ run: docker image push 'netdata/netdata@${{ steps.build.outputs.digest }}'
190
+# - name: Push to GitHub Container Registry
191
+# id: push-ghcr
192
+# if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch' && steps.docker-hub-login.outcome == 'success'
193
+# continue-on-error: true
194
+# run: docker image push 'netdata/netdata@${{ steps.build.outputs.digest }}'
195
+ - name: Push to Quay.io
196
+ id: push-quay
197
+ if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch' && steps.docker-hub-login.outcome == 'success'
198
+ continue-on-error: true
199
+ run: docker image push 'quay.io/netdata/netdata@${{ steps.build.outputs.digest }}'
200
- name: Export Digest
201
id: export-digest
202
if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch'
@@ -214,6 +232,8 @@ jobs:
232
Login to Quay: ${{ steps.quay-login.outcome }}
233
Build image: ${{ steps.build.outcome }}
234
Test image: ${{ steps.test.outcome }}
235
+ Push to Docker Hub: ${{ steps.push-docker-hub.outcome }}
236
+ Push to Quay: ${{ steps.push-quay.outcome }}
237
Export digest: ${{ steps.export-digest.outcome }}
238
Upload digest: ${{ steps.upload-digest.outcome }}
239
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}