I know we can auto delete branches when PR gets merged on Github. Is there a way we can get branches to auto delete when PR is closed?
I do not see an option in Settings tab of Repo for deleting branches when PR gets closed
CodePudding user response:
While completing the PR, we have a Checkbox, when selected will delete the source branch as soon as we complete the PR.
As soon as you click on Complete, there is a Checkbox for Deleting the source branch. Select the respective Checkbox, and Click on Complete to complete the PR and for deleting the SOURCE branch.
CodePudding user response:
As there is no inbuilt functionality for this on Github, I used github actions for this. Here's a snippet on how we can get this done:
steps:
- name: Delete closed PR branch
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{github.token}}
numbers: ${{github.event.pull_request.number}}