Skip to content

Commit

Permalink
Re-try docker push several times before giving up
Browse files Browse the repository at this point in the history
  • Loading branch information
psalz committed Sep 10, 2024
1 parent 198cc28 commit c6042fa
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/build_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,20 @@ jobs:
run: bash ./build.sh -f ${{ matrix.ubuntu-version }} ${{ matrix.sycl }} ${{ matrix.sycl-version }}
if: ${{ github.event_name != 'schedule' }}
# NOTE: Since `docker login` is stateful, we race with other jobs that run concurrently on the same machine, which may
# result in spurious authentication failures. We reduce the likelihood of this by logging in right before pushing.
- name: Log into Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# result in spurious authentication failures. We re-try several times before giving up.
- name: Push Docker containers for ${{ matrix.sycl }} ${{ matrix.sycl-version }} on ${{ matrix.ubuntu-version }}
run: |
for REPOSITORY in "${{ matrix.sycl }}" "celerity-build/${{ matrix.sycl }}"; do
IMAGE="$REPOSITORY:ubuntu${{ matrix.ubuntu-version }}-${{ matrix.sycl-version }}"
docker tag $IMAGE ghcr.io/celerity/$IMAGE
docker push ghcr.io/celerity/$IMAGE
attempts=0
done=0
while [[ $done -ne 1 && $attempts -lt 5 ]]; do
docker login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
{ docker push ghcr.io/celerity/$IMAGE && done=1 } || true
sleep $(( (2 ** attempts) - 1 ))
attempts=$(( attempts + 1 ))
done
done
build-lint:
needs: [check-prerequisites]
Expand Down

0 comments on commit c6042fa

Please sign in to comment.