From ae83a39fa8cf4230f23b81e49667e8d6745c7429 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 15 Oct 2026 13:23:41 -0500 Subject: [PATCH] Add Rerun Failed Jobs For Current Branch as a GitHub TIL --- README.md | 3 +- .../rerun-failed-jobs-for-current-branch.md | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 github/rerun-failed-jobs-for-current-branch.md diff --git a/README.md b/README.md index 99b47a8..dfc48fe 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/). For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1889 TILs and counting..._ +_1890 TILs and counting..._ See some of the other learning resources I work on: @@ -486,6 +486,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Open A PR To An Unforked Repo](github/open-a-pr-to-an-unforked-repo.md) - [Open File To Specific Line In Browser](github/open-file-to-specific-line-in-browser.md) - [Process JSON Output From gh With jq](github/process-json-output-from-gh-with-jq.md) +- [Rerun Failed Jobs For Current Branch](github/rerun-failed-jobs-for-current-branch.md) - [Target Another Repo When Creating A PR](github/target-another-repo-when-creating-a-pr.md) - [Tell gh What The Default Repo Is](github/tell-gh-what-the-default-repo-is.md) diff --git a/github/rerun-failed-jobs-for-current-branch.md b/github/rerun-failed-jobs-for-current-branch.md new file mode 100644 index 0000000..6c60247 --- /dev/null +++ b/github/rerun-failed-jobs-for-current-branch.md @@ -0,0 +1,30 @@ +# Rerun Failed Jobs For Current Branch + +I have a branch that I've already opened a PR for. I've made more changes, run +the tests, and pushed up the latest to the remote. I know the tests should have +been green, but I'm seeing a flickering test fail in CI. I want to retrigger the +relevant failed jobs to see if I can get the flickers to pass. + +First, I need to figure out the workflow ID with any failed jobs. + +```bash +❯ gh run list --branch "$(git branch --show-current)" --status failure +STATUS TITLE WORKFLOW BRANCH EVENT ID ELAPSED AGE +X Better comp... Ruby on R... jbranchau... pull_request 38778306948 10m54s about 25 ... +``` + +This one-liner does that by referencing the current branch (via `git`) and then +asking `gh` to list failed workflows associated with that branch. + +Grabbing the `ID` value, I can then ask `gh` to rerun failed jobs for that +workflow. + +```bash +❯ gh run rerun 38778306948 --failed +✓ Requested rerun (failed jobs) of run 38778306948 +``` + +Opening that PR up in the browser, I can see that the specific workflow has been +rerun and is currently _in progress_. + +See `gh run list --help` and `gh run rerun --help` for more details.