-
Notifications
You must be signed in to change notification settings - Fork 2.8k
74 lines (62 loc) · 2.59 KB
/
Copy pathissue-close-require.yml
File metadata and controls
74 lines (62 loc) · 2.59 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Issue Close Require
on:
schedule:
- cron: '0 0 * * *'
permissions:
issues: write
jobs:
close-issues:
runs-on: ubuntu-latest
steps:
- name: close stale issues by label
uses: actions/github-script@v7
with:
script: |
const INACTIVE_DAYS = 3;
const cutoff = Date.now() - INACTIVE_DAYS * 24 * 60 * 60 * 1000;
const targets = [
{
label: '🤔 Need Reproduce',
body: `Since the issue was labeled with \`🤔 Need Reproduce\`, but no response in 3 days. This issue will be closed. If you have any questions, you can comment and reply.
由于该 issue 被标记为需要重现(🤔 Need Reproduce),却 3 天未收到回应。现关闭 issue,若有任何问题,可评论回复。`,
},
{
label: 'needs more info',
body: `Since the issue was labeled with \`needs more info\`, but no response in 3 days. This issue will be closed. If you have any questions, you can comment and reply.
由于该 issue 被标记为需要更多信息,却 3 天未收到回应。现关闭 issue,若有任何问题,可评论回复。`,
},
];
const closed = [];
for (const target of targets) {
const issues = await github.paginate(github.rest.issues.listForRepo, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: target.label,
per_page: 100,
});
for (const issue of issues) {
if (issue.pull_request) {
continue;
}
const updatedAt = new Date(issue.updated_at).getTime();
if (Number.isNaN(updatedAt) || updatedAt > cutoff) {
continue;
}
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: target.body,
});
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'closed',
state_reason: 'not_planned',
});
closed.push(`#${issue.number}(${target.label})`);
}
}
core.info(`Closed ${closed.length} issue(s): ${closed.join(', ')}`);