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

View File

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