A GitHub action to close a pull request and optionally delete its branch.
❗ Using this action is no longer necessary |
---|
The same functionality exists in the GitHub CLI. See the documentation here.
- name: Close Pull
run: gh pr close --comment "Auto-closing pull request" --delete-branch "1"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
If you prefer to use this action:
- name: Close Pull
uses: peter-evans/close-pull@v3
with:
pull-request-number: 1
comment: Auto-closing pull request
delete-branch: true
Name | Description | Default |
---|---|---|
token |
GITHUB_TOKEN or a repo scoped PAT. |
GITHUB_TOKEN |
repository |
The GitHub repository containing the pull request. | Current repository |
pull-request-number |
The number of the pull request to close. | github.event.number |
comment |
A comment to make on the pull request before closing. | |
delete-branch |
Delete the pull request branch. | false |
Note: Deleting branches will fail silently for pull requests to public repositories from forks. Private repositories can be configured to enable workflows from forks to run without restriction.
You can close pull requests in another repository by using a PAT instead of GITHUB_TOKEN
.
The user associated with the PAT must have write access to the repository.