Skip to content

Commit 48a35d8

Browse files
authored
Merge pull request #172 from WyriHaximusNet/retry-docker-commands-on-failure
Retry Docker commands on failure
2 parents 94c3307 + c544d5f commit 48a35d8

1 file changed

Lines changed: 44 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ jobs:
134134
- uses: actions/checkout@v2
135135
- uses: dbhi/qus/action@main
136136
- run: mkdir ./docker-image/
137-
- run: ./build-php.sh $(echo "${{ matrix.image }}" | tr '-' ' ') ${{ matrix.arch }}
137+
- uses: nick-invision/retry@v2
138+
with:
139+
timeout_minutes: 120
140+
retry_wait_seconds: 30
141+
max_attempts: 5
142+
command: ./build-php.sh $(echo "${{ matrix.image }}" | tr '-' ' ') ${{ matrix.arch }}
138143
- run: cat ./docker-image/image.tags | xargs -I % docker inspect --format='%={{.Id}}:{{index .Config.Env 7}}' %
139144
- run: docker save "${DOCKER_IMAGE}" | gzip -9 > ./docker-image/image.tar
140145
- run: docker images
@@ -231,18 +236,33 @@ jobs:
231236
path: ./docker-image
232237
- run: docker load --input ./docker-image/image.tar
233238
- name: Login to container registries
234-
run: |
235-
(jq -r 'to_entries | map("echo \"$" + .value + "\" | docker login " + .key + " --username \"${{ env.DOCKER_USER }}\" --password-stdin") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
239+
uses: nick-invision/retry@v2
240+
with:
241+
timeout_minutes: 120
242+
retry_wait_seconds: 30
243+
max_attempts: 5
244+
command: |
245+
(jq -r 'to_entries | map("echo \"$" + .value + "\" | docker login " + .key + " --username \"${{ env.DOCKER_USER }}\" --password-stdin") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
236246
env:
237247
DOCKER_USER: ${{ secrets.HUB_USERNAME }}
238248
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
239249
HUB_PASSCODE: ${{ secrets.HUB_PASSCODE }}
240250
- name: Retag
241-
run: |
242-
(jq -r 'to_entries | map("cat ./docker-image/image.tags | xargs -I % docker tag % " + .key + "/%") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
251+
uses: nick-invision/retry@v2
252+
with:
253+
timeout_minutes: 120
254+
retry_wait_seconds: 30
255+
max_attempts: 5
256+
command: |
257+
(jq -r 'to_entries | map("cat ./docker-image/image.tags | xargs -I % docker tag % " + .key + "/%") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
243258
- name: Push tags
244-
run: |
245-
(jq -r 'to_entries | map("cat ./docker-image/image.tags | xargs -I % docker push " + .key + "/%") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
259+
uses: nick-invision/retry@v2
260+
with:
261+
timeout_minutes: 120
262+
retry_wait_seconds: 30
263+
max_attempts: 5
264+
command: |
265+
(jq -r 'to_entries | map("cat ./docker-image/image.tags | xargs -I % docker push " + .key + "/%") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
246266
push-manifest:
247267
name: Push ${{ matrix.image }} manifest
248268
if: (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/master'
@@ -264,19 +284,29 @@ jobs:
264284
name: docker-image-${{ matrix.image }}-amd64
265285
path: ./docker-image
266286
- name: Login to container registries
267-
run: |
268-
(jq -r 'to_entries | map("echo \"$" + .value + "\" | docker login " + .key + " --username \"${{ env.DOCKER_USER }}\" --password-stdin") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
287+
uses: nick-invision/retry@v2
288+
with:
289+
timeout_minutes: 120
290+
retry_wait_seconds: 30
291+
max_attempts: 5
292+
command: |
293+
(jq -r 'to_entries | map("echo \"$" + .value + "\" | docker login " + .key + " --username \"${{ env.DOCKER_USER }}\" --password-stdin") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
269294
env:
270295
DOCKER_USER: ${{ secrets.HUB_USERNAME }}
271296
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
272297
HUB_PASSCODE: ${{ secrets.HUB_PASSCODE }}
273298
- name: Docker info
274299
run: docker info
275300
- name: Push manifest to registries
276-
run: |
277-
touch command.sh
278-
(jq -r 'to_entries | map("cat ./docker-image/image.tags | xargs -I % php utils/create-manifest-command.php " + .key + " %") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
279-
chmod +x command.sh
280-
./command.sh
301+
uses: nick-invision/retry@v2
302+
with:
303+
timeout_minutes: 120
304+
retry_wait_seconds: 30
305+
max_attempts: 5
306+
command: |
307+
touch command.sh
308+
(jq -r 'to_entries | map("cat ./docker-image/image.tags | xargs -I % php utils/create-manifest-command.php " + .key + " %") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
309+
chmod +x command.sh
310+
./command.sh
281311
env:
282312
TARGET_ARCHS: ${{ needs.supported-arch-matrix.outputs.arch }}

0 commit comments

Comments
 (0)