https://github.com/peter-evans/close-pull
A GitHub action to close a pull request and optionally delete its branch.
https://github.com/peter-evans/close-pull
automation close-pull close-pull-request github-action workflow
Last synced: 5 months ago
JSON representation
A GitHub action to close a pull request and optionally delete its branch.
- Host: GitHub
- URL: https://github.com/peter-evans/close-pull
- Owner: peter-evans
- License: mit
- Created: 2020-05-02T03:56:35.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-09-07T21:30:21.000Z (almost 2 years ago)
- Last Synced: 2025-03-16T13:17:09.521Z (about 1 year ago)
- Topics: automation, close-pull, close-pull-request, github-action, workflow
- Homepage:
- Size: 1.08 MB
- Stars: 22
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Close Pull
[](https://github.com/peter-evans/close-pull/actions?query=workflow%3ACI)
[](https://github.com/marketplace/actions/close-pull)
A GitHub action to close a pull request and optionally delete its branch.
## Usage
| :exclamation: Using this action is no longer necessary |
|-----------------------------------------------------------|
The same functionality exists in the GitHub CLI. See the documentation [here](https://cli.github.com/manual/gh_pr_close).
```yml
- 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:
```yml
- name: Close Pull
uses: peter-evans/close-pull@v3
with:
pull-request-number: 1
comment: Auto-closing pull request
delete-branch: true
```
### Action inputs
| Name | Description | Default |
| --- | --- | --- |
| `token` | `GITHUB_TOKEN` or a `repo` scoped [PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token). | `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](https://docs.github.com/en/github/administering-a-repository/disabling-or-limiting-github-actions-for-a-repository#enabling-workflows-for-private-repository-forks) from forks to run without restriction.
### Accessing pull requests in other repositories
You can close pull requests in another repository by using a [PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) instead of `GITHUB_TOKEN`.
The user associated with the PAT must have write access to the repository.
## License
[MIT](LICENSE)