Add workflow to rerun potentially transient failures #1
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
| # Workflow runs on main, on a release branch, and that were triggered as part of a merge group have | ||
|
Check failure on line 1 in .github/workflows/deflake.yml
|
||
| # already passed CI before being merged. Therefore if they fail, we should make sure that there | ||
| # wasn't a transient failure by rerunning the failed jobs once before investigating further. | ||
| name: Deflake | ||
| on: | ||
| workflow_run: | ||
| types: [completed] | ||
| jobs: | ||
| rerun-on-failure: | ||
| name: Rerun failed workflows | ||
| if: >- | ||
| github.event.workflow_run.conclusion == 'failure' && | ||
| github.event.workflow_run.run_attempt == 1 && | ||
| ( | ||
| github.event.workflow_run.head_branch == 'main' || | ||
| startsWith(github.event.workflow_run.head_branch, 'releases/') || | ||
| github.event.workflow_run.event == 'merge_group' | ||
| ) | ||
| runs-on: ubuntu-slim | ||
| permissions: | ||
| actions: write | ||
| steps: | ||
| - name: Rerun failed jobs in ${{ github.event.workflow_run.name }} | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| GH_REPO: ${{ github.repository }} | ||
| RUN_ID: ${{ github.event.workflow_run.id }} | ||
| RUN_NAME: ${{ github.event.workflow_run.name }} | ||
| RUN_URL: ${{ github.event.workflow_run.html_url }} | ||
| run: | | ||
| echo "Rerunning failed jobs for workflow run ${RUN_ID}" | ||
| gh run rerun "${RUN_ID}" --failed | ||
| echo "### Reran failed jobs :recycle:" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "Workflow: [${RUN_NAME}](${RUN_URL})" >> "$GITHUB_STEP_SUMMARY" | ||