forked from jbetancur/react-data-table-component
-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (39 loc) · 1.56 KB
/
close-empty-issues.yml
File metadata and controls
45 lines (39 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Close empty issues
on:
issues:
types: [opened, edited]
jobs:
check:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/github-script@v7
with:
script: |
const body = context.payload.issue.body ?? '';
// Strip HTML comments (template instructions), whitespace, and checkboxes
const stripped = body
.replace(/<!--[\s\S]*?-->/g, '')
.replace(/- \[[ x]\]/g, '')
.trim();
// Close if body is missing or under 50 meaningful characters
if (stripped.length >= 50) return;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
body: [
"Thanks for opening an issue. It looks like the description is empty or incomplete.",
"",
"Please fill out the issue template with enough detail to reproduce or understand the problem — a description, steps to reproduce, and your version. Issues without this information are difficult to act on and may be closed.",
"",
"Feel free to reopen once you've added more detail.",
].join('\n'),
});
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
state: 'closed',
});