Skip to content

Retry failed jobs once #4304

Retry failed jobs once

Retry failed jobs once #4304

name: Retry failed jobs once
on:
workflow_run: # zizmor: ignore[dangerous-triggers]
workflows:
- "CI"
- "E2E Fleet"
- "E2E Upgrade Fleet Standalone to HEAD"
- "E2E Multi-Cluster Fleet"
- "E2E Nightly Fleet"
- "Benchmarks"
types: [completed]
permissions:
actions: write
jobs:
retry:
# Only retry once, only on failure.
# Skipped runs (e.g. path filters) have conclusion 'skipped', not 'failure'.
# Retry pull_request runs for all listed PR workflows.
# Retry schedule/workflow_dispatch runs only for nightly and benchmark workflows.
if: >-
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.run_attempt == 1 &&
github.event.workflow_run.head_repository.full_name == github.repository &&
(github.event.workflow_run.event == 'pull_request' ||
github.event.workflow_run.name == 'E2E Nightly Fleet' ||
github.event.workflow_run.name == 'Benchmarks')
runs-on: ubuntu-latest
steps:
- name: Rerun failed jobs
env:
GH_TOKEN: ${{ github.token }}
RUN_ID: ${{ github.event.workflow_run.id }}
run: |
gh api \
--method POST \
"repos/${{ github.repository }}/actions/runs/$RUN_ID/rerun-failed-jobs"