-
-
Notifications
You must be signed in to change notification settings - Fork 182
39 lines (36 loc) · 1.19 KB
/
Copy pathissue-close-require.yml
File metadata and controls
39 lines (36 loc) · 1.19 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
name: Issue Close Require
on:
schedule:
- cron: "0 0 * * *"
permissions:
issues: write
jobs:
close-issues:
runs-on: ubuntu-latest
steps:
- name: need reproduction
uses: actions/github-script@v9
with:
script: |
const inactiveDays = 3;
const cutoff = new Date(Date.now() - inactiveDays * 24 * 60 * 60 * 1000);
const issues = await github.paginate(github.rest.issues.listForRepo, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'need reproduction',
per_page: 100,
});
for (const issue of issues) {
if (issue.pull_request) continue;
if (new Date(issue.updated_at) < cutoff) {
console.log(`Closing #${issue.number} (last updated ${issue.updated_at})`);
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'closed',
state_reason: 'not_planned',
});
}
}