From e7a1f346e8781eb6047f6fc442d480589b4e1c02 Mon Sep 17 00:00:00 2001 From: Tracewebstudio Dev Date: Wed, 29 Apr 2026 10:39:56 +0200 Subject: [PATCH] fix(ci): retry buildx push and fallback without cache export --- .gitea/workflows/build.yaml | 40 +++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 167e58c..f3cf3da 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -162,11 +162,35 @@ jobs: exit 0 fi - docker buildx build --push \ - -f Dockerfile.simple \ - --build-arg SERVICE_NAME=${{ matrix.service }} \ - --cache-from type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache \ - --cache-to type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache,mode=max \ - -t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:${{ gitea.sha }}" \ - -t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:high-performance-latest" \ - . + build_with_cache() { + docker buildx build --push \ + -f Dockerfile.simple \ + --build-arg SERVICE_NAME=${{ matrix.service }} \ + --cache-from type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache \ + --cache-to type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache,mode=max \ + -t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:${{ gitea.sha }}" \ + -t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:high-performance-latest" \ + . + } + + build_without_cache_export() { + docker buildx build --push \ + -f Dockerfile.simple \ + --build-arg SERVICE_NAME=${{ matrix.service }} \ + --cache-from type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache \ + -t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:${{ gitea.sha }}" \ + -t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:high-performance-latest" \ + . + } + + for attempt in 1 2 3; do + echo "Build attempt $attempt with cache export for ${{ matrix.service }}" + if build_with_cache; then + exit 0 + fi + echo "Attempt $attempt failed; retrying after backoff" + sleep $((attempt * 10)) + done + + echo "Falling back to build without cache export for ${{ matrix.service }}" + build_without_cache_export