Skip to content

Commit 4fd8de0

Browse files
committed
Add workflow to rerun potentially transient failures
1 parent e2d518d commit 4fd8de0

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

.github/workflows/deflake.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Workflow runs on main, on a release branch, and that were triggered as part of a merge group have
2+
# already passed CI before being merged. Therefore if they fail, we should make sure that there
3+
# wasn't a transient failure by rerunning the failed jobs once before investigating further.
4+
name: Deflake
5+
6+
on:
7+
workflow_run:
8+
types: [completed]
9+
10+
jobs:
11+
rerun-on-failure:
12+
name: Rerun failed workflows
13+
if: >-
14+
github.event.workflow_run.conclusion == 'failure' &&
15+
github.event.workflow_run.run_attempt == 1 &&
16+
(
17+
github.event.workflow_run.head_branch == 'main' ||
18+
startsWith(github.event.workflow_run.head_branch, 'releases/') ||
19+
github.event.workflow_run.event == 'merge_group'
20+
)
21+
runs-on: ubuntu-slim
22+
permissions:
23+
actions: write
24+
steps:
25+
- name: Rerun failed jobs in ${{ github.event.workflow_run.name }}
26+
env:
27+
GH_TOKEN: ${{ github.token }}
28+
GH_REPO: ${{ github.repository }}
29+
RUN_ID: ${{ github.event.workflow_run.id }}
30+
RUN_NAME: ${{ github.event.workflow_run.name }}
31+
RUN_URL: ${{ github.event.workflow_run.html_url }}
32+
run: |
33+
echo "Rerunning failed jobs for workflow run ${RUN_ID}"
34+
gh run rerun "${RUN_ID}" --failed
35+
echo "### Reran failed jobs :recycle:" >> "$GITHUB_STEP_SUMMARY"
36+
echo "" >> "$GITHUB_STEP_SUMMARY"
37+
echo "Workflow: [${RUN_NAME}](${RUN_URL})" >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)