Auto-Retry Failed Run #1456
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto-Retry Failed Run | |
| # Trigger under the same conditions as Tests workflow | |
| on: | |
| workflow_run: | |
| workflows: ["Tests"] | |
| types: | |
| - completed | |
| workflow_dispatch: # Added to test and debug if required | |
| inputs: | |
| workflow_run_id: | |
| description: 'Workflow run ID to retry' | |
| required: true | |
| type: string | |
| permissions: | |
| actions: write # Required to modify/rerun workflows | |
| contents: read | |
| jobs: | |
| rerun-on-failure: | |
| if: ${{ (github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.run_attempt == 1) || github.event_name == 'workflow_dispatch' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Retry failed workflow | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| REPO: ${{ github.repository }} | |
| RUN_ID: ${{ github.event.workflow_run.id || github.event.inputs.workflow_run_id }} | |
| run: | | |
| echo "Retrying workflow run: $RUN_ID" | |
| sleep 30 | |
| gh run rerun $RUN_ID --failed --repo $REPO |