Skip to content

Latest commit

 

History

History
63 lines (47 loc) · 2.24 KB

README.md

File metadata and controls

63 lines (47 loc) · 2.24 KB

Remove merged branches

Remove the branches that were merged in the branch in which you run this action.

⚠️ Warning

  • Do you really need this? GitHub can also delete branches automatically after PR has been merged. See managing the automatic deletion of branches. This Action is useful when your workflow does not merge changes (after PR) against your default branch directly.
  • This action WILL delete branches! Please do your due diligence before using this tool. The provider of this software will not take liability over any mishaps that may occur.

⚙️ How does it work?

  1. Using git, all merged branches in the current branch ($GITHUB_ACTION_REF) are fetched
  2. Branches are removed, except for:
  • current branch
  • the branches added to the ignore list
  1. Message is logged for each branch that is removed or ignored

ATTENTION: some branches are ignored by default, see considerations.

🚀 Running in GitHub Actions

Run this action in Github Actions by adding pcvg/remove-merged-branches@main to your steps.

Parameters

Name Meaning Default Required
protected_branch Branch that will be ignored in the removal process - false

Example

In the below example all branches merged to main will be removed:

name: Remove merged branches
on:
  push:
    branches:
      - main

jobs:
  remove-branches:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Remove branches
        uses: pcvg/remove-merged-branches@main
        with:
          protected_branch: some-branch

Considerations

  • Any branch that is a copy of the default branch (without any diff) will also be removed
  • Following branches will be ignored and not removed by default:
    • main
    • staging
    • production
    • master

⚖️ License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.