From e54440ad807fe850c556f5bf818be5636c81e35b Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Wed, 2 Jul 2025 23:37:05 +0800 Subject: [PATCH] chore: retry workflow for r2 uploading (#1517) --- .github/workflows/retry-workflow.yml | 18 ++++++++++++++++++ .github/workflows/upload-to-r2.yml | 14 +++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/retry-workflow.yml diff --git a/.github/workflows/retry-workflow.yml b/.github/workflows/retry-workflow.yml new file mode 100644 index 00000000..0219289b --- /dev/null +++ b/.github/workflows/retry-workflow.yml @@ -0,0 +1,18 @@ +name: Retry workflow + +on: + workflow_dispatch: + inputs: + run_id: + required: true +jobs: + rerun: + runs-on: ubuntu-latest + steps: + - name: rerun ${{ inputs.run_id }} + env: + GH_REPO: ${{ github.repository }} + GH_TOKEN: ${{ github.token }} + run: | + gh run watch ${{ inputs.run_id }} > /dev/null 2>&1 + gh run rerun ${{ inputs.run_id }} --failed diff --git a/.github/workflows/upload-to-r2.yml b/.github/workflows/upload-to-r2.yml index 46b267c2..6b68c378 100644 --- a/.github/workflows/upload-to-r2.yml +++ b/.github/workflows/upload-to-r2.yml @@ -20,8 +20,6 @@ jobs: timeout-minutes: 3 strategy: fail-fast: false - matrix: - attempt: [1, 2, 3] env: RELEASE_R2_BUCKET: readest-releases RELEASE_R2_ACCOUNT_ID: ${{ secrets.RELEASE_R2_ACCOUNT_ID }} @@ -66,4 +64,14 @@ jobs: - name: Upload successful if: success() - run: echo "Upload completed successfully on attempt ${{ matrix.attempt }}" + run: echo "Upload completed successfully" + + retry-on-failure: + if: failure() && fromJSON(github.run_attempt) < 3 + needs: [upload-to-r2] + runs-on: ubuntu-latest + steps: + - env: + GH_REPO: ${{ github.repository }} + GH_TOKEN: ${{ github.token }} + run: gh workflow run retry-workflow.yml -F run_id=${{ github.run_id }}