Add Rerun Failed Jobs For Current Branch as a GitHub TIL

This commit is contained in:
jbranchaud
2026-10-15 13:23:41 -05:00
parent c301401663
commit ae83a39fa8
2 changed files with 32 additions and 1 deletions
+2 -1
View File
@@ -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)
@@ -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.