mirror of
https://github.com/desktop/desktop
synced 2024-10-30 06:03:10 +00:00
Merge pull request #18091 from desktop/close-single-word-issues
Add a new action to automatically close issues with single-word titles
This commit is contained in:
commit
db23071c4b
1 changed files with 41 additions and 0 deletions
41
.github/workflows/close-single-word-issues.yml
vendored
Normal file
41
.github/workflows/close-single-word-issues.yml
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
name: Close Single-Word Issues
|
||||
|
||||
on:
|
||||
issues:
|
||||
types:
|
||||
- opened
|
||||
|
||||
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.`
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue