Skip to content

Add workflow to retry failed PR jobs once#4812

Merged
thardeck merged 1 commit intomainfrom
add_retry_failed_jobs
Mar 13, 2026
Merged

Add workflow to retry failed PR jobs once#4812
thardeck merged 1 commit intomainfrom
add_retry_failed_jobs

Conversation

@thardeck
Copy link
Collaborator

When a workflow run triggered by a pull request fails on its first attempt, automatically rerun only the failed jobs. This catches transient failures (flaky tests, network timeouts, resource contention) without manual intervention.

  • retry-failed-jobs.yml listens for workflow_run completions, guards on run_attempt == 1 and event == 'pull_request', and calls the GitHub API rerun-failed-jobs endpoint. Only the actions: write permission from the default GITHUB_TOKEN is required — no GitHub App or custom token needed.

@thardeck thardeck self-assigned this Mar 13, 2026
@thardeck thardeck added this to Fleet Mar 13, 2026
@thardeck thardeck requested a review from a team as a code owner March 13, 2026 09:17
Copilot AI review requested due to automatic review settings March 13, 2026 09:17
@thardeck thardeck moved this to 👀 In review in Fleet Mar 13, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a GitHub Actions workflow that automatically retries only the failed jobs for pull-request workflow runs that fail on their first attempt, aiming to reduce manual reruns for transient failures.

Changes:

  • Introduces a workflow_run-triggered workflow that detects failed PR runs with run_attempt == 1.
  • Uses the GitHub API (rerun-failed-jobs) via gh api authenticated with the default GITHUB_TOKEN and actions: write.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

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.
@thardeck thardeck force-pushed the add_retry_failed_jobs branch from e8a01f0 to 2a3164e Compare March 13, 2026 09:38
@thardeck thardeck merged commit 4e59ee8 into main Mar 13, 2026
22 checks passed
@thardeck thardeck deleted the add_retry_failed_jobs branch March 13, 2026 10:11
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Fleet Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants