This GitHub action will fetch all the files inside of .github/ISSUE_TEMPLATE, parse the titles and compare those titles with the content of the opened/edited issue, if they don't match, it will:
- Add a label to the issue (configurable with the input property
closed-issues-label);This step won't run if no label is provided.
- Add a message to the issue;
- Close it.
If the user happens to edit the issue to match the template, the action will run again and, if it matches, it will remove the label and reopen the issue automatically.
This will only work if you have the input property
closed-issues-labelprovided.
Put the following content in the file .github/workflows/main.yml:
on: issues: types: [opened, edited] jobs: auto_close_issues: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v1 - name: Automatically close issues that don't follow the issue template uses: ergo720/auto-close-issues@v1.0.4 with: github-token: ${{ secrets.GITHUB_TOKEN }} issue-close-message: "@${issue.user.login}: hello! :wave:\n\nThis issue is being automatically closed because it does not follow the issue template." # optional property closed-issues-label: "🙁 Not following issue template" # optional propertyYou can configure issue-close-message and closed-issues-label, which are, respectively, the message that is shown when closing the issue and the label added to the issue when it being closed.
For issue-close-message the example configuration uses issue.user.login to mention the user's username, you can check what you can specify on the message on GitHub webhook documentation.
This project is released under the MIT license.