Skip to content

Commit fc4a312

Browse files
committed
chore: add GitHub Actions workflow to auto-retry failed runs
Add .github/workflows/retry.yml that triggers on workflow_run completion events for the main branch. When a workflow fails on its first attempt, automatically reruns only the failed jobs using the GitHub CLI. Excludes the retry workflow itself from triggering to prevent infinite loops.
1 parent 21fcdef commit fc4a312

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

.github/workflows/retry.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: retry
2+
on:
3+
workflow_run:
4+
workflows: ['**']
5+
types:
6+
- completed
7+
branches:
8+
- main
9+
10+
jobs:
11+
retry:
12+
runs-on: ubuntu-latest
13+
if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.run_attempt == 1 && github.event.workflow_run.name != 'retry' }}
14+
permissions:
15+
actions: write
16+
steps:
17+
- name: Retry failed workflow
18+
run: |
19+
echo "Retrying workflow: ${{ github.event.workflow_run.name }} (run ${{ github.event.workflow_run.id }})"
20+
gh run rerun "${{ github.event.workflow_run.id }}" --repo "${{ github.event.repository.full_name }}" --failed
21+
env:
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)