diff --git a/.github/workflows/close-untitled-issues.yml b/.github/workflows/close-untitled-issues.yml new file mode 100644 index 0000000..06abecb --- /dev/null +++ b/.github/workflows/close-untitled-issues.yml @@ -0,0 +1,43 @@ +name: Close untitled issues + +on: + issues: + types: [opened] + +permissions: + issues: write + +jobs: + check-title: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Close if title is empty or generic + uses: actions/github-script@v7 + with: + script: | + const title = context.payload.issue.title.trim(); + const badTitles = [ + "[bug]", + "bug report", + "bug", + "issue", + ]; + + if (badTitles.includes(title.toLowerCase())) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.issue.number, + body: "This issue was closed because no title was provided. Please re-open with a descriptive title that summarizes the problem." + }); + + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.issue.number, + state: "closed", + state_reason: "not_planned" + }); + }