From ce939501ea2a93f5ac7d8d121ab507189b46601f Mon Sep 17 00:00:00 2001 From: siritami <102145692+FiorenMas@users.noreply.github.com> Date: Fri, 1 Mar 2024 14:07:01 +0700 Subject: [PATCH] update workflow Workflow will retry more 2 times before stop the workflow if github connection not stable --- .github/actions/re-run/action.yml | 24 +++++++++++++++ .github/workflows/ci.yml | 28 ++++++++++++++++++ .github/workflows/manual-patch.yml | 47 +++++++++++++++++++++--------- 3 files changed, 86 insertions(+), 13 deletions(-) create mode 100644 .github/actions/re-run/action.yml diff --git a/.github/actions/re-run/action.yml b/.github/actions/re-run/action.yml new file mode 100644 index 0000000..612fd13 --- /dev/null +++ b/.github/actions/re-run/action.yml @@ -0,0 +1,24 @@ +name: Re-run workflow if github connection not stable +runs: + using: "composite" + steps: + - name: Re-run workflow if github connection not stable + uses: actions/github-script@v7 + with: + script: | + const maxRetries = ${{ env.max_retries }}; + let retryCount = Number('${{ env.retry_count }}'); + const orgInput = '${{ github.event.inputs.org }}' || '${{ inputs.org }}'; + if (retryCount < maxRetries) { + retryCount += 1; + await github.rest.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: "manual-patch.yml", + ref: context.ref, + inputs: { + 'retry_count': String(retryCount), + 'org': orgInput + } + }); + } \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cec2957..45deb96 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,11 @@ on: schedule: - cron: "0 */6 * * *" workflow_dispatch: + inputs: + retry_count: + description: 'Do not change value below' + required: false + default: '1' jobs: check: name: Check new patch @@ -43,6 +48,29 @@ jobs: - name: Keep workflow run if: steps.check-gh.outputs.internet_error == '0' uses: gautamkrishnar/keepalive-workflow@v1 + - name: Re-run workflow if github connection not stable + if: always() && steps.check-rv.outcome == 'skipped' && env.retry_count < env.max_retries + uses: actions/github-script@v7 + with: + script: | + const maxRetries = ${{ env.max_retries }}; + let retryCount = ${{ env.retry_count }}; + if (retryCount < maxRetries) { + retryCount += 1; + await github.rest.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: "ci.yml", + ref: context.ref, + inputs: { + 'retry_count': String(retryCount) + } + }); + } + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + retry_count: ${{ github.event.inputs.retry_count }} + max_retries: 3 outputs: check_rv: ${{ steps.check-rv.outputs.new_patch }} check_rv_beta: ${{ steps.check-rv-beta.outputs.new_patch }} diff --git a/.github/workflows/manual-patch.yml b/.github/workflows/manual-patch.yml index 91f58a0..433336d 100644 --- a/.github/workflows/manual-patch.yml +++ b/.github/workflows/manual-patch.yml @@ -1,5 +1,10 @@ name: Manual Patch permissions: write-all +env: + repository: ${{ github.repository }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + retry_count: ${{ github.event.inputs.retry_count }} + max_retries: 3 on: workflow_dispatch: inputs: @@ -16,6 +21,10 @@ on: - 'Revanced Extended' - 'Revanced Extended Android 6,7' - 'Revanced Extended Android 5' + retry_count: + description: 'Do not change value below' + required: false + default: '1' workflow_call: inputs: org: @@ -45,13 +54,15 @@ jobs: if: steps.check-gh.outputs.internet_error == '0' uses: ./.github/actions/preparing - name: Patch apk + id: patch if: steps.check-gh.outputs.internet_error == '0' run: bash src/build/Revanced-${{ matrix.Include.run }}.sh - env: - repository: ${{ github.repository }} - name: Releasing APK files if: steps.check-gh.outputs.internet_error == '0' uses: ./.github/actions/release + - name: Re-run workflow if github connection not stable + if: always() && steps.patch.outcome == 'skipped' && env.retry_count < env.max_retries && matrix.Include.run == '1' + uses: ./.github/actions/re-run patch_rv_beta: name: Patch Revanced Beta if: ${{ github.event.inputs.org == 'Revanced Beta' || github.event.inputs.org == 'All' || inputs.org == 'Revanced Beta' }} @@ -66,13 +77,15 @@ jobs: if: steps.check-gh.outputs.internet_error == '0' uses: ./.github/actions/preparing - name: Patch apk + id: patch if: steps.check-gh.outputs.internet_error == '0' run: bash src/build/Revanced-Beta.sh - env: - repository: ${{ github.repository }} - name: Releasing APK files if: steps.check-gh.outputs.internet_error == '0' uses: ./.github/actions/release + - name: Re-run workflow if github connection not stable + if: always() && steps.patch.outcome == 'skipped' && env.retry_count < env.max_retries + uses: ./.github/actions/re-run patch_rex: name: Patch ReX if: ${{ github.event.inputs.org == 'ReX' || github.event.inputs.org == 'All' || inputs.org == 'ReX' }} @@ -87,13 +100,15 @@ jobs: if: steps.check-gh.outputs.internet_error == '0' uses: ./.github/actions/preparing - name: Patch apk + id: patch if: steps.check-gh.outputs.internet_error == '0' run: bash src/build/ReX.sh - env: - repository: ${{ github.repository }} - name: Releasing APK files if: steps.check-gh.outputs.internet_error == '0' uses: ./.github/actions/release + - name: Re-run workflow if github connection not stable + if: always() && steps.patch.outcome == 'skipped' && env.retry_count < env.max_retries + uses: ./.github/actions/re-run patch_rve: name: Patch Revanced Extended if: ${{ github.event.inputs.org == 'Revanced Extended' || github.event.inputs.org == 'All' || inputs.org == 'Revanced Extended' }} @@ -108,13 +123,15 @@ jobs: if: steps.check-gh.outputs.internet_error == '0' uses: ./.github/actions/preparing - name: Patch apk + id: patch if: steps.check-gh.outputs.internet_error == '0' run: bash src/build/Revanced-Extended.sh - env: - repository: ${{ github.repository }} - name: Releasing APK files if: steps.check-gh.outputs.internet_error == '0' uses: ./.github/actions/release + - name: Re-run workflow if github connection not stable + if: always() && steps.patch.outcome == 'skipped' && env.retry_count < env.max_retries + uses: ./.github/actions/re-run patch_rve67: name: Revanced Extended Android 6,7 if: ${{ github.event.inputs.org == 'Revanced Extended Android 6,7' || github.event.inputs.org == 'All' || inputs.org == 'Revanced Extended Android 6,7' }} @@ -129,13 +146,15 @@ jobs: if: steps.check-gh.outputs.internet_error == '0' uses: ./.github/actions/preparing - name: Patch apk + id: patch if: steps.check-gh.outputs.internet_error == '0' run: bash src/build/Revanced-Extended-Android-6-7.sh - env: - repository: ${{ github.repository }} - name: Releasing APK files if: steps.check-gh.outputs.internet_error == '0' uses: ./.github/actions/release + - name: Re-run workflow if github connection not stable + if: always() && steps.patch.outcome == 'skipped' && env.retry_count < env.max_retries + uses: ./.github/actions/re-run patch_rve5: name: Revanced Extended Android 5 if: ${{ github.event.inputs.org == 'Revanced Extended Android 5' || github.event.inputs.org == 'All' || inputs.org == 'Revanced Extended Android 5' }} @@ -147,13 +166,15 @@ jobs: id: check-gh run: bash src/etc/connection.sh - name: Preparing to patch + id: patch if: steps.check-gh.outputs.internet_error == '0' uses: ./.github/actions/preparing - name: Patch apk if: steps.check-gh.outputs.internet_error == '0' run: bash src/build/Revanced-Extended-Android-5.sh - env: - repository: ${{ github.repository }} - name: Releasing APK files if: steps.check-gh.outputs.internet_error == '0' - uses: ./.github/actions/release \ No newline at end of file + uses: ./.github/actions/release + - name: Re-run workflow if github connection not stable + if: always() && steps.patch.outcome == 'skipped' && env.retry_count < env.max_retries + uses: ./.github/actions/re-run \ No newline at end of file