Skip to content

Commit d4056a8

Browse files
authored
auto-close with comment (#409)
1 parent 3d71fe8 commit d4056a8

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

scripts/update-issues.ts

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,19 +321,51 @@ async function update() {
321321
// web-features or if we change the format of the issue body.
322322
if (dryRun) {
323323
console.log(`Dry run. Would update issue for ${id}.`);
324-
continue;
324+
} else {
325+
console.log(`Updating issue for ${id}.`);
326+
await octokit.rest.issues.update({
327+
...params,
328+
issue_number: issue.number,
329+
title,
330+
body,
331+
// Labels are not updated to avoid removing labels added manually.
332+
});
325333
}
326-
console.log(`Updating issue for ${id}.`);
327-
await octokit.rest.issues.update({
328-
...params,
329-
issue_number: issue.number,
330-
title,
331-
body,
332-
// Labels are not updated to avoid removing labels added manually.
333-
});
334334
} else {
335335
console.log(`Issue for ${id} is up-to-date.`);
336336
}
337+
338+
if (data.status.baseline) {
339+
// The feature has reached Baseline status since this issue was opened, so we should close it.
340+
const closeComment = dedent`
341+
This feature reached Baseline status on ${dateFormat.format(new Date(data.status.baseline_low_date))}, which means it's now fully supported across browsers. Developer signals are no longer needed for this feature, so this issue can be closed.
342+
343+
Thank you to everyone who provided feedback! 🎉
344+
`;
345+
346+
if (dryRun) {
347+
console.log(`Dry run. Would close issue for ${id} with comment.`);
348+
} else {
349+
console.log(`Closing issue for ${id} with comment.`);
350+
351+
// Post the comment
352+
await octokit.rest.issues.createComment({
353+
...params,
354+
issue_number: issue.number,
355+
body: closeComment,
356+
});
357+
358+
// Close the issue
359+
await octokit.rest.issues.update({
360+
...params,
361+
issue_number: issue.number,
362+
state: "closed",
363+
});
364+
}
365+
366+
continue;
367+
}
368+
337369
manifest.set(id, {
338370
url: issue.html_url,
339371
// Only count 👍 reactions as "votes".

0 commit comments

Comments
 (0)