From 2a3164e9bcaec2c6184a61f2b9bd6f723f6f81fd Mon Sep 17 00:00:00 2001 From: Tim Hardeck Date: Fri, 13 Mar 2026 09:22:50 +0100 Subject: [PATCH] Add workflow to retry failed PR jobs once When a workflow run triggered by a pull_request event fails on its first attempt, automatically rerun only the failed jobs. Uses the default GITHUB_TOKEN with actions:write permission via the GitHub API endpoint POST /actions/runs/{run_id}/rerun-failed-jobs. --- .github/workflows/retry-failed-jobs.yml | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/retry-failed-jobs.yml diff --git a/.github/workflows/retry-failed-jobs.yml b/.github/workflows/retry-failed-jobs.yml new file mode 100644 index 0000000000..31e2726427 --- /dev/null +++ b/.github/workflows/retry-failed-jobs.yml @@ -0,0 +1,32 @@ +name: Retry failed PR jobs once + +on: + workflow_run: + workflows: + - "CI" + - "E2E Fleet" + - "E2E Upgrade Fleet Standalone to HEAD" + - "E2E Multi-Cluster Fleet" + types: [completed] + +permissions: + actions: write + +jobs: + retry: + # Only retry once, only on pull_request runs, only on failure. + # Skipped runs (e.g. path filters) have conclusion 'skipped', not 'failure'. + if: >- + github.event.workflow_run.conclusion == 'failure' && + github.event.workflow_run.run_attempt == 1 && + github.event.workflow_run.event == 'pull_request' + 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"