From a1442fc06201b0f356ed99ceb2cd38fff20d6cb7 Mon Sep 17 00:00:00 2001 From: Huarch Date: Fri, 24 Apr 2026 16:07:59 +0800 Subject: [PATCH] ci: retry registry pushes Retry Docker image pushes to the Gitea registry so transient EOF failures during blob upload do not fail the whole CD run on the first attempt. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .gitea/workflows/package.yml | 24 ++++++++++++++++++++++-- memery.md | 2 ++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/package.yml b/.gitea/workflows/package.yml index b28e96f..639e848 100644 --- a/.gitea/workflows/package.yml +++ b/.gitea/workflows/package.yml @@ -77,6 +77,26 @@ jobs: - name: Build and Push Image run: | + push_with_retry() { + image_ref="$1" + attempt=1 + max_attempts=3 + + while [ "$attempt" -le "$max_attempts" ]; do + if docker push "$image_ref"; then + return 0 + fi + + if [ "$attempt" -eq "$max_attempts" ]; then + return 1 + fi + + echo "Push failed for $image_ref (attempt $attempt/$max_attempts); retrying in 10s..." + attempt=$((attempt + 1)) + sleep 10 + done + } + docker build \ -f ./Dockerfile \ -t "${IMAGE_NAME}:${IMAGE_TAG}" \ @@ -91,8 +111,8 @@ jobs: --build-arg NEXT_PUBLIC_MAPBOX_TOKEN="${{ secrets.NEXT_PUBLIC_MAPBOX_TOKEN }}" \ --build-arg NEXT_PUBLIC_TIANDITU_TOKEN="${{ secrets.NEXT_PUBLIC_TIANDITU_TOKEN }}" \ . - docker push "${IMAGE_NAME}:${IMAGE_TAG}" - docker push "${IMAGE_NAME}:latest" + push_with_retry "${IMAGE_NAME}:${IMAGE_TAG}" + push_with_retry "${IMAGE_NAME}:latest" - name: Notify Deploy Server run: | diff --git a/memery.md b/memery.md index 5a47dd0..c19a0d4 100644 --- a/memery.md +++ b/memery.md @@ -16,5 +16,7 @@ - **Follow-up from server validation:** the runner still executed `Notify Deploy Server` for `v2026.04.24-test5`, so Gitea step-level `if:` with `endsWith(...)` was not sufficient in this environment. - **Applied hardening:** replaced those step-level conditions with direct shell `case "${{ github.ref_name }}" in *-test)` guards inside the login, push, and deploy steps. This avoids relying on Gitea expression behavior for test-tag skipping. - **Workflow mode changed for full CD verification:** per latest request, all `*-test` bypass logic was removed again so the workflow always runs registry login, image push, and deploy webhook. Full deployment validation now depends on using a normal `v*` tag and observing the real CD result instead of synthetic skip branches. +- **Next full-CD failure on act_runner:** image build completed, but pushing to the Gitea registry failed on blob upload commit with `failed to do request: Put ... EOF`. This is past the workflow logic stage and points to a transient or infrastructure-side registry upload failure. +- **Applied push hardening:** wrapped both `docker push "${IMAGE_NAME}:${IMAGE_TAG}"` and `docker push "${IMAGE_NAME}:latest"` in a 3-attempt retry helper with a short backoff to absorb transient registry EOF failures. - **Current local result:** `npm run lint`, `npm run test -- --runInBand`, `npm run build`, `docker build ...`, and `npm run build` inside `gitea/runner-images:ubuntu-22.04` all completed successfully after the workflow adjustment. - **Non-blocking note:** local Jest run reported a haste-map naming collision between `package.json` and `.next/standalone/package.json`; tests still passed, and this does not affect the current image-build workflow.