Skip to content

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

License

Notifications You must be signed in to change notification settings

peter-evans/close-pull

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Close Pull

CI GitHub Marketplace

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

Usage

❗ 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

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 to public repositories from forks. Private repositories can be configured to enable workflows from forks to run without restriction.

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