Skip to content

Commit 1c55e70

Browse files
gtwang01facebook-github-bot
authored andcommitted
Auto-retry failed CI builds once
Summary: As title Differential Revision: D60697701
1 parent 0b2328f commit 1c55e70

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.github/workflows/retry_build.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Retry Build
2+
on:
3+
workflow_run:
4+
workflows: [Build]
5+
types:
6+
- completed
7+
jobs:
8+
on-success:
9+
runs-on: ubuntu-latest
10+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
11+
steps:
12+
- run: echo 'The triggering workflow passed. No action will be taken.'
13+
on-failure:
14+
runs-on: ubuntu-latest
15+
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
16+
steps:
17+
- run: |
18+
echo 'The triggering workflow failed. Retrying once.'
19+
20+
# get run id and rerun
21+
RUNID=$(gh api repos/$OWNER/$REPO/commits/$COMMIT_SHA/check-runs |
22+
jq -r '.check_runs[] |
23+
select(.name == "Build") |
24+
.html_url |
25+
capture("/runs/(?<number>[0-9]+)/job") |
26+
.number' |
27+
sed 's/"//g' |
28+
head -n 1)
29+
30+
gh run rerun $RUNID --failed

0 commit comments

Comments
 (0)