-
Notifications
You must be signed in to change notification settings - Fork 355
57 lines (47 loc) · 2.23 KB
/
check-undocumented-issues.yml
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
46
47
48
49
50
51
52
53
54
55
56
57
name: Check Undocumented Issues
on:
issues:
types: [opened]
jobs:
check-issue-content:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Check issue content
uses: actions/github-script@v7
with:
script: |
const issue = context.payload.issue;
// Get the issue body and title
const body = issue.body || '';
const title = issue.title || '';
// Check if this is a docs update request
const isDocsRequest = title.startsWith('Docs update request:');
if (!isDocsRequest) {
return;
}
// Split body into lines and remove empty ones
const bodyLines = body.split('\n').filter(line => line.trim());
// Check if only contains the template content
const hasOnlyTemplate =
bodyLines.length <= 3 && // Updated to match 3 lines
bodyLines[0]?.startsWith('Source:') &&
bodyLines[1]?.startsWith('Request: (how can we help?)') &&
bodyLines[2]?.includes('Psst, this issue will be closed'); // Added check for the warning message
if (hasOnlyTemplate) {
// Close the issue with a comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: 'This issue is being closed automatically as it appears to be an empty documentation update request. Please provide specific details about what needs to be updated or improved in the documentation. You can create a new issue with more details if needed.\n\nSome helpful details to include:\n- What specific part of the documentation needs updating?\n- What is unclear or missing?\n- What would make the documentation more helpful?\n\nThank you for helping us improve our documentation!'
});
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'closed',
state_reason: 'not_planned'
});
}