Skip to content

Commit b95a9ad

Browse files
authored
Add scheduled auto-closure for stale “Needs Author Feedback” issues (#566)
1 parent 2adacc2 commit b95a9ad

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Close inactive author feedback issues
2+
3+
on:
4+
schedule:
5+
- cron: "0 9 * * *"
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
issues: write
11+
12+
jobs:
13+
close-inactive:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Close issues waiting on author feedback
17+
uses: actions/github-script@v7
18+
with:
19+
github-token: ${{ secrets.GITHUB_TOKEN }}
20+
script: |
21+
const label = "Needs Author Feedback";
22+
const daysInactive = 7;
23+
const cutoff = new Date(Date.now() - daysInactive * 24 * 60 * 60 * 1000);
24+
25+
const { owner, repo } = context.repo;
26+
const issues = await github.paginate(github.rest.issues.listForRepo, {
27+
owner,
28+
repo,
29+
state: "open",
30+
labels: label,
31+
per_page: 100,
32+
sort: "updated",
33+
direction: "asc",
34+
});
35+
36+
for (const issue of issues) {
37+
if (issue.pull_request) {
38+
continue;
39+
}
40+
41+
const updatedAt = new Date(issue.updated_at);
42+
if (updatedAt > cutoff) {
43+
continue;
44+
}
45+
46+
const body = [
47+
"We haven't heard back in 7 days, so we're automatically closing this issue.",
48+
"If you still need help, please reply and we can reopen it."
49+
].join("\n\n");
50+
51+
try {
52+
await github.rest.issues.createComment({ owner, repo, issue_number: issue.number, body });
53+
} catch (error) {
54+
console.warn(`Skipping issue #${issue.number} because of an error while adding the notice: ${error}`);
55+
continue;
56+
}
57+
58+
try {
59+
await github.rest.issues.update({ owner, repo, issue_number: issue.number, state: "closed" });
60+
} catch (error) {
61+
console.warn(`Skipping issue #${issue.number} because of an error while processing closure: ${error}`);
62+
}
63+
}

0 commit comments

Comments
 (0)