Skip to content

Commit 97144bf

Browse files
authored
Automatically re-run failed jobs (#2795)
Some CI jobs are a bit flaky, without an obvious way for us to fix them. Instead, I've added a new job that checks if any job failed, and re-runs them automatically.
1 parent 82ee203 commit 97144bf

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,15 @@ jobs:
9292
if [[ $passed != "true" ]]; then
9393
exit 1
9494
fi
95+
96+
re-run:
97+
name: Re-run failed jobs
98+
needs: lint-build-test
99+
if: failure() && fromJSON(github.run_attempt) < 3
100+
runs-on: ubuntu-latest
101+
steps:
102+
- env:
103+
GH_REPO: ${{ github.repository }}
104+
GH_TOKEN: ${{ github.token }}
105+
GH_DEBUG: api
106+
run: gh workflow run re-run.yml -F run-id=${{ github.run_id }}

.github/workflows/re-run.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on:
2+
workflow_dispatch:
3+
inputs:
4+
run-id:
5+
required: true
6+
7+
jobs:
8+
rerun:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: rerun ${{ inputs.run-id }}
12+
env:
13+
GH_REPO: ${{ github.repository }}
14+
GH_TOKEN: ${{ github.token }}
15+
GH_DEBUG: api
16+
run: |
17+
gh run watch ${{ inputs.run-id }} > /dev/null 2>&1
18+
gh run rerun ${{ inputs.run-id }} --failed

0 commit comments

Comments
 (0)