590A:31190E:55961D:614135:6A2E7EBC 4749:3F74A7:557C25:6126CC:6A2E7EC8 1BEF:1F740:1FF85B2:25A654C:6A2E7F40 4514:84E8E:1F1A697:24CAFBF:6A2E7F99 1BEF:1F740:2010C6F:25C2827:6A2E7FB8 #3295
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Close Single-Word Issues | |
| on: | |
| issues: | |
| types: | |
| - opened | |
| permissions: | |
| issues: write | |
| jobs: | |
| close-issue: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Close Single-Word Issue | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const issueTitle = context.payload.issue.title.trim(); | |
| const isSingleWord = /^\S+$/.test(issueTitle); | |
| if (isSingleWord) { | |
| const issueNumber = context.payload.issue.number; | |
| const repo = context.repo.repo; | |
| // Close the issue and add the invalid label | |
| github.rest.issues.update({ | |
| owner: context.repo.owner, | |
| repo: repo, | |
| issue_number: issueNumber, | |
| labels: ['invalid'], | |
| state: 'closed' | |
| }); | |
| // Comment on the issue | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: repo, | |
| issue_number: issueNumber, | |
| body: `This issue may have been opened accidentally. I'm going to close it now, but feel free to open a new issue with a more descriptive title.` | |
| }); | |
| } |