-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·57 lines (53 loc) · 1.89 KB
/
Copy pathgit-issue-auto-close.yml
File metadata and controls
executable file
·57 lines (53 loc) · 1.89 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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Close issue
run-name: Auto close inactive issues with schedule
on:
schedule:
- cron: "0 0 */7 * *"
jobs:
close-issues:
permissions:
issues: write
runs-on: ubuntu-latest
steps:
- name: 😞 Check labels and close inactive issues
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const inactiveDays = 7
const cutoff = Date.now() - inactiveDays * 24 * 60 * 60 * 1000
const labels = ['status|waiting-reproduction', 'status|waiting-feedback']
const owner = context.repo.owner
const repo = context.repo.repo
const issues = await github.paginate(github.rest.issues.listForRepo, {
owner,
repo,
state: 'open',
labels: labels.join(','),
sort: 'updated',
direction: 'asc',
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
const body = [
'Hi, this issue has been closed because it has been inactive for more than 7 days.',
'If you think it should still be open, please reply here.'
].join('\n')
await github.rest.issues.createComment({
owner,
repo,
issue_number: issue.number,
body
})
await github.rest.issues.update({
owner,
repo,
issue_number: issue.number,
state: 'closed'
})
}