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

Clone this repo:

Branches

  1. b3a2b29 Keep branch if it is a base branch of another PR in same repo (#17) by Haralan Dobrev · 2 weeks ago master
  2. 7c9e85b Env variables need quotes, strings for everyone! (#16) by Frederic Barthelemy · 2 weeks ago
  3. f88217c Update ToC for README.md by toc-me[bot] · 5 weeks ago
  4. 8bc6dd7 Add a customization point to configure no-branch-deleted exit code (#13) by Frederic Barthelemy · 5 weeks ago
  5. 22adf60 Create FUNDING.yml by Jess Frazelle · 5 weeks ago

Branch Cleanup Action

Travis CI

A GitHub action to automatically delete the branch after a pull request has been merged. Here's a blog post describing this action in more detail.

NOTE: This will never delete the repository's default branch. If the pull request is closed without merging, it will not delete it.

Table of Contents

Usage

workflow "on pull request merge, delete the branch" {
  on = "pull_request"
  resolves = ["branch cleanup"]
}

action "branch cleanup" {
  uses = "jessfraz/branch-cleanup-action@master"
  secrets = ["GITHUB_TOKEN"]
}

If you include this in another Workflow, you may want to configure the environment variable NO_BRANCH_DELETED_EXIT_CODE. The default value for this is 78, as Github Actions will mark a check as “neutral” (neither failed/succeeded) when you exit with code 78. This will however cancel any other actions running in parallel in this workflow.

If you don't want it to cancel, configure your workflow as follows:

action "branch cleanup" {
  uses = "jessfraz/branch-cleanup-action@master"
  secrets = ["GITHUB_TOKEN"]

  env = {
    NO_BRANCH_DELETED_EXIT_CODE = "0"
  }
}

demo

Contributing

Running the tests

The tests use shellcheck. You don't need to install anything (assuming you have docker installed). The tests run in a container.

$ make test