Skip to content

Commit 1e08d93

Browse files
committed
tooling(actions): adds action to close issues without enough information
1 parent 6e07900 commit 1e08d93

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// @ts-check
2+
const {
3+
labels: { planning },
4+
} = require("./support/resources");
5+
6+
/** @param {import('github-script').AsyncFunctionArguments} AsyncFunctionArguments */
7+
module.exports = async ({ github, context }) => {
8+
const { repo, owner } = context.repo;
9+
const DAYS_BEFORE_CLOSE = 14;
10+
11+
console.log(`Checking for issues with the label: "${planning.needsInfo}" that are stale.`);
12+
13+
// Get all issues with the specific label
14+
const { data: issues } = await github.rest.issues.listForRepo({
15+
owner: owner,
16+
repo: repo,
17+
state: "open",
18+
labels: planning.needsInfo,
19+
per_page: 100,
20+
});
21+
22+
const now = new Date();
23+
24+
for (const issue of issues) {
25+
const lastUpdated = new Date(issue.updated_at);
26+
const daysSinceUpdate = Math.round((now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24));
27+
28+
//remove this later
29+
console.log(`Days since update: ${daysSinceUpdate}`);
30+
31+
if (daysSinceUpdate >= DAYS_BEFORE_CLOSE) {
32+
console.log(`Closing issue #${issue.number} - No updates for ${Math.round(daysSinceUpdate)} days`);
33+
34+
await github.rest.issues.createComment({
35+
owner: owner,
36+
repo: repo,
37+
issue_number: issue.number,
38+
body: "Closing this issue due to inactivity. If this is still an issue, it can be reopened once additional information has been provided.",
39+
});
40+
41+
await github.rest.issues.update({
42+
issue_number: issue.number,
43+
owner: owner,
44+
repo: repo,
45+
state: "closed",
46+
});
47+
}
48+
}
49+
50+
console.log("Finished checking for issues without enough information.");
51+
};

.github/scripts/support/resources.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const resources = {
2727
planning: {
2828
needsTriage: "needs triage",
2929
needsMilestone: "needs milestone",
30+
needsInfo: "needs more info",
3031
spike: "spike",
3132
spikeComplete: "spike complete",
3233
noChangelogEntry: "no changelog entry",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Close Need More Info Issues
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 0 * * *" # Runs daily at midnight UTC
7+
8+
permissions:
9+
issues: write
10+
11+
jobs:
12+
close-needs-more-info-issues:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v4
17+
18+
- name: Close issue if more info is not provided
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
const action = require('${{ github.workspace }}/.github/scripts/closeNeedMoreInfoIssues.js')
23+
await action({github, context, core})

0 commit comments

Comments
 (0)