update workflow

Workflow will retry more 2 times before stop the workflow if github connection not stable
This commit is contained in:
siritami
2024-03-01 14:07:01 +07:00
parent ebe3fe1b26
commit ce939501ea
3 changed files with 86 additions and 13 deletions

24
.github/actions/re-run/action.yml vendored Normal file
View File

@@ -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
}
});
}

View File

@@ -4,6 +4,11 @@ on:
schedule: schedule:
- cron: "0 */6 * * *" - cron: "0 */6 * * *"
workflow_dispatch: workflow_dispatch:
inputs:
retry_count:
description: 'Do not change value below'
required: false
default: '1'
jobs: jobs:
check: check:
name: Check new patch name: Check new patch
@@ -43,6 +48,29 @@ jobs:
- name: Keep workflow run - name: Keep workflow run
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
uses: gautamkrishnar/keepalive-workflow@v1 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: outputs:
check_rv: ${{ steps.check-rv.outputs.new_patch }} check_rv: ${{ steps.check-rv.outputs.new_patch }}
check_rv_beta: ${{ steps.check-rv-beta.outputs.new_patch }} check_rv_beta: ${{ steps.check-rv-beta.outputs.new_patch }}

View File

@@ -1,5 +1,10 @@
name: Manual Patch name: Manual Patch
permissions: write-all permissions: write-all
env:
repository: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
retry_count: ${{ github.event.inputs.retry_count }}
max_retries: 3
on: on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
@@ -16,6 +21,10 @@ on:
- 'Revanced Extended' - 'Revanced Extended'
- 'Revanced Extended Android 6,7' - 'Revanced Extended Android 6,7'
- 'Revanced Extended Android 5' - 'Revanced Extended Android 5'
retry_count:
description: 'Do not change value below'
required: false
default: '1'
workflow_call: workflow_call:
inputs: inputs:
org: org:
@@ -45,13 +54,15 @@ jobs:
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
uses: ./.github/actions/preparing uses: ./.github/actions/preparing
- name: Patch apk - name: Patch apk
id: patch
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
run: bash src/build/Revanced-${{ matrix.Include.run }}.sh run: bash src/build/Revanced-${{ matrix.Include.run }}.sh
env:
repository: ${{ github.repository }}
- name: Releasing APK files - name: Releasing APK files
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
uses: ./.github/actions/release 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: patch_rv_beta:
name: Patch Revanced Beta name: Patch Revanced Beta
if: ${{ github.event.inputs.org == 'Revanced Beta' || github.event.inputs.org == 'All' || inputs.org == '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' if: steps.check-gh.outputs.internet_error == '0'
uses: ./.github/actions/preparing uses: ./.github/actions/preparing
- name: Patch apk - name: Patch apk
id: patch
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
run: bash src/build/Revanced-Beta.sh run: bash src/build/Revanced-Beta.sh
env:
repository: ${{ github.repository }}
- name: Releasing APK files - name: Releasing APK files
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
uses: ./.github/actions/release 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: patch_rex:
name: Patch ReX name: Patch ReX
if: ${{ github.event.inputs.org == 'ReX' || github.event.inputs.org == 'All' || inputs.org == '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' if: steps.check-gh.outputs.internet_error == '0'
uses: ./.github/actions/preparing uses: ./.github/actions/preparing
- name: Patch apk - name: Patch apk
id: patch
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
run: bash src/build/ReX.sh run: bash src/build/ReX.sh
env:
repository: ${{ github.repository }}
- name: Releasing APK files - name: Releasing APK files
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
uses: ./.github/actions/release 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: patch_rve:
name: Patch Revanced Extended name: Patch Revanced Extended
if: ${{ github.event.inputs.org == 'Revanced Extended' || github.event.inputs.org == 'All' || inputs.org == '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' if: steps.check-gh.outputs.internet_error == '0'
uses: ./.github/actions/preparing uses: ./.github/actions/preparing
- name: Patch apk - name: Patch apk
id: patch
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
run: bash src/build/Revanced-Extended.sh run: bash src/build/Revanced-Extended.sh
env:
repository: ${{ github.repository }}
- name: Releasing APK files - name: Releasing APK files
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
uses: ./.github/actions/release 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: patch_rve67:
name: Revanced Extended Android 6,7 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' }} 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' if: steps.check-gh.outputs.internet_error == '0'
uses: ./.github/actions/preparing uses: ./.github/actions/preparing
- name: Patch apk - name: Patch apk
id: patch
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
run: bash src/build/Revanced-Extended-Android-6-7.sh run: bash src/build/Revanced-Extended-Android-6-7.sh
env:
repository: ${{ github.repository }}
- name: Releasing APK files - name: Releasing APK files
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
uses: ./.github/actions/release 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: patch_rve5:
name: Revanced Extended Android 5 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' }} 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 id: check-gh
run: bash src/etc/connection.sh run: bash src/etc/connection.sh
- name: Preparing to patch - name: Preparing to patch
id: patch
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
uses: ./.github/actions/preparing uses: ./.github/actions/preparing
- name: Patch apk - name: Patch apk
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
run: bash src/build/Revanced-Extended-Android-5.sh run: bash src/build/Revanced-Extended-Android-5.sh
env:
repository: ${{ github.repository }}
- name: Releasing APK files - name: Releasing APK files
if: steps.check-gh.outputs.internet_error == '0' if: steps.check-gh.outputs.internet_error == '0'
uses: ./.github/actions/release 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