Skip to content

peter-evans/close-issue

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 Issue

CI GitHub Marketplace

A GitHub action to close an issue.

Usage

❗ Using this action is no longer necessary

The same functionality exists in the GitHub CLI. See the documentation here.

    - name: Close Issue
      run: gh issue close --comment "Auto-closing issue" "1"
      env:
        GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

If you prefer to use this action:

      - name: Close Issue
        uses: peter-evans/close-issue@v3
        with:
          issue-number: 1
          comment: Auto-closing issue

Close issues where the title does not match a specified prefix

This is just an example to show one way in which this action can be used.

on:
  issues:
    types: [opened]
jobs:
  titlePrefixCheck:
    runs-on: ubuntu-latest
    steps:
      - if: startsWith(github.event.issue.title, 'ABC-') != 'true'
        name: Close Issue
        uses: peter-evans/close-issue@v3
        with:
          comment: |
            Issue title must start with 'ABC-'.
            Auto-closing this issue.

Close issue and add label(s)

      - name: Close Issue
        uses: peter-evans/close-issue@v3
        with:
          issue-number: 1
          comment: Auto-closing issue
          labels: |
            wontfix

Action inputs

Name Description Default
token GITHUB_TOKEN or a repo scoped PAT. GITHUB_TOKEN
repository The GitHub repository containing the issue. Current repository
issue-number The number of the issue to close. github.event.issue.number
close-reason Reason for closing the issue; completed or not_planned. completed
comment A comment to make on the issue before closing.
labels A comma or newline separated list of labels.

Accessing issues in other repositories

You can close issues 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