Skip to content

rickstaa/empty-issues-closer-action

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

Repository files navigation

typescript-action status

Empty Issues Closer action

A GitHub Action that automatically closes empty issues or issues which contain an unchanged (markdown) template.

  • Closes issues with an empty issue body.
  • Reopens non-empty issues.
  • Closes issues which do not fill in the (markdown) issue template.
  • Reopens issues in which the (markdown) issue template was filled in.

Table of content

Examples

Empty issue closed

image

Non-empty issue re-opened

image

Pre-requisites

Create a workflow .yml file in your .github/workflows directory. An example workflow is available below. For more information, reference the GitHub Help Documentation for creating a workflow file.

Inputs

Various inputs are defined in action.yml to let you configure the action:

Name Description Default
github_token Token used for authorizing interactions with the repository. Typically the GITHUB_TOKEN secret. N/A
close_comment Comment posted when a GitHub issue is closed because it is empty. Closing this issue because it appears to be empty. Please update the issue for it to be reopened.
open_comment Comment posted when a GitHub issue is reopened because it is no longer empty. Reopening this issue because the author provided more information.
check_templates Whether to also check for issues with unchanged issue templates. false
template_close_comment Comment posted when a template issue is closed. Closing this issue since the issue template was not filled in. Please provide us with more information to have this issue reopened.
template_open_comment Comment posted when a template issue is reopened. Reopening this issue because the author provided more information.
dry_run Run the action without actually closing/opening the issues. false

Warning

The action looks for markdown templates in the .github/ISSUE_TEMPLATE folder. Please ensure that you added your templates to this folder for the check_templates action to work. This action only checks markdown based issue templates since for YAML based GitHub form schema templates GitHub provides the validations property which can be used to prevent empty form templates from being submitted.

Outputs

This action currently does not have any outputs.

Examples workflow - Close empty issues

The following example uses the issue event to run the empty-issues-closer-action every time an issue is opened, reopened or edited to close empty issues.

name: Close empty issues
on:
  issues:
    types:
      - reopened
      - opened
      - edited

jobs:
  closeEmptyIssues:
    name: Close empty issues
    runs-on: ubuntu-latest
    steps:
    - name: Run empty issues closer action
      uses: rickstaa/empty-issues-closer-action@v1
      env:
        github_token: ${{ secrets.GITHUB_TOKEN }}
      with:
        close_comment: Closing this issue because it appears to be empty. Please update the issue for it to be reopened.
        open_comment: Reopening this issue because the author provided more information.

Examples workflow - Close empty issues and templates

The following example uses the issue event to run the empty-issues-closer-action every time an issue is opened, reopened or edited with all features enabled.

name: Close empty issues and templates
on:
  issues:
    types:
      - reopened
      - opened
      - edited

jobs:
  closeEmptyIssuesAndTemplates:
    name: Close empty issues and templates
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3 # NOTE: Retrieve issue templates.
    - name: Run empty issues closer action
      uses: rickstaa/empty-issues-closer-action@v1
      env:
        github_token: ${{ secrets.GITHUB_TOKEN }}
      with:
        close_comment: Closing this issue because it appears to be empty. Please update the issue for it to be reopened.
        open_comment: Reopening this issue because the author provided more information.
        check_templates: true
        template_close_comment: Closing this issue since the issue template was not filled in. Please provide us with more information to have this issue reopened.
        template_open_comment: Reopening this issue because the author provided more information.

Warning

Please make sure that you use the actions/checkout action to checkout the repository when you want to use the check_templates option.

FAQ

How does this differ from the 'blank_issues_enabled' key in the template chooser config

As of October 28, 2019, users can use a template configuration file to configure the issue templates. The blank_issues_enabled option allows you to show or hide the 'Open a blank issue' choice when users select the 'New issue' button in your repository.

Open a black issue

This option, however, doesn't prevent users from creating empty issues using the /issues/new path. This GitHub action automatically closes empty issues or issues with an unchanged template.

How to prevent empty YAML-based templates from being submitted

For issue templates that are written in YAML (i.e. GitHub form schema templates), GitHub provides the validations property, which can be used to prevent empty templates from being submitted (see the GitHub documentation for more information).

Contributing

Feel free to open an issue if you have ideas on improving this GitHub action or if you would like to report a bug! Just so you know, all contributions are welcome. 🚀 Please consult the contribution guidelines for more information.