Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
git-pull-request

GitHub Action

Close Pull

v1.0.0

Close Pull

git-pull-request

Close Pull

A GitHub action to close a pull request and optionally delete its branch

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Close Pull

uses: peter-evans/close-pull@v1.0.0

Learn more about this action in peter-evans/close-pull

Choose a version

Close Pull

GitHub Marketplace

A GitHub action to close a pull request and optionally delete its branch.

Usage

Close a pull request and delete its branch

      - name: Close Pull
        uses: peter-evans/close-pull@v1
        with:
          pull-request-number: 1
          comment: Auto-closing pull request
          delete-branch: true

Reject all pull requests to a repository

on:
  pull_request:
    types: [opened]
jobs:
  closePullRequest:
    runs-on: ubuntu-latest
    steps:
      - name: Close Pull
        uses: peter-evans/close-pull@v1
        with:
          comment: |
            Sorry. Pull requests are not accepted for this repository.
            Auto-closing this pull request.

Action inputs

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 from forks.

Accessing pull requests in other repositories

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.

License

MIT