finds.dev← search

// the find

jessfraz/branch-cleanup-action

★ 422 · Shell · MIT · updated Mar 2022

A GitHub action to automatically delete the branch after a pull request has been merged.

A shell-script GitHub Action that deletes a PR's branch once the PR is merged, skipping the default branch and any protected branches. It's for repo maintainers who don't want stale merged branches piling up and haven't already turned on GitHub's native setting that does the same thing.

The whole action is one small shell script (cleanup-pr-branch) plus a Dockerfile, so you can read the entire thing in a couple of minutes instead of trusting a black box. It explicitly guards against deleting the default branch or protected branches, and it exits with a distinct code (78) so a 'nothing to delete' run shows up as neutral rather than failed. Tests run shellcheck in a Docker container via a plain Makefile, which is a low-friction way to keep a shell script honest.

The README's usage example is written in the old HCL workflow syntax from GitHub Actions' pre-GA days, not the YAML format every workflow has used since late 2019 — copy-pasting it as-is won't work, and there's no updated example. No commits since March 2022, and in the meantime GitHub added a native 'automatically delete head branches' repository setting that does exactly this for free, which makes the action redundant for most users. It still uses Travis CI for its own tests, another sign the project is frozen in an earlier GitHub ecosystem. There are no version tags/releases, so the only documented way to consume it is pinning to @master, which is a rough security practice for a third-party action with write access to your repo.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →