Skip to content

Commit f4083ec

Browse files
author
NullPointerException
committed
update issue action
1 parent 09c4507 commit f4083ec

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ assignees: ''
1111
- [ ] I make sure that there are no *existing issues* - open or closed - which I could contribute my information to.
1212

1313
<hr>
14+
15+
** Description
16+
(Start here)

.github/workflows/close-issues.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Close Issues if Template Ignored
2+
3+
on:
4+
issues:
5+
types: [opened]
6+
7+
jobs:
8+
close_issues:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Check issue body and creation date
13+
uses: actions/github-script@v6
14+
with:
15+
script: |
16+
const issueBody = context.payload.issue.body;
17+
const issueNumber = context.payload.issue.number;
18+
const issueCreatedAt = new Date(context.payload.issue.created_at);
19+
const templateKeyword = "**Checklist "; // Change this to a unique part of your template
20+
21+
// Define the cutoff date (year, month - 1, day)
22+
const cutoffDate = new Date(2024, 11, 2); // December is month 11 (0-based index)
23+
24+
// Check if the issue was created after the cutoff date
25+
if (issueCreatedAt > cutoffDate) {
26+
// Check if the issue body contains the template keyword
27+
if (!issueBody.includes(templateKeyword)) {
28+
await github.rest.issues.createComment({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
issue_number: issueNumber,
32+
body: "This issue does not follow the template and will be closed. Please update the issue following the template and reopen it."
33+
});
34+
35+
await github.rest.issues.update({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
issue_number: issueNumber,
39+
state: "closed"
40+
});
41+
}
42+
}

0 commit comments

Comments
 (0)