-
Notifications
You must be signed in to change notification settings - Fork 136
43 lines (40 loc) · 1.28 KB
/
Copy pathlock-closed.yml
File metadata and controls
43 lines (40 loc) · 1.28 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
name: Lock closed issues
on:
schedule:
- cron: "0 14 * * *"
workflow_dispatch:
permissions:
issues: write
jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v9
with:
script: |
const THIRTY_DAYS = 30 * 24 * 60 * 60 * 1000;
const cutoff = Date.now() - THIRTY_DAYS;
const issues = await github.paginate(github.rest.issues.listForRepo, {
owner: context.repo.owner,
repo: context.repo.repo,
state: "closed",
sort: "updated",
direction: "asc",
per_page: 100,
});
let locked = 0;
for (const issue of issues) {
if (issue.pull_request) continue; // skip PRs
if (issue.locked) continue;
if (new Date(issue.updated_at).getTime() < cutoff) {
await github.rest.issues.lock({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
lock_reason: "resolved",
});
console.log(`Locked #${issue.number}`);
locked++;
}
}
console.log(`Done. Locked ${locked} issue(s).`);