|
1 | | -name: Close and Mark Stale Issues |
| 1 | +name: 'Close stale issues and PRs' |
2 | 2 | on: |
3 | 3 | schedule: |
4 | | - - cron: "0 0 * * *" |
| 4 | + - cron: '30 1 * * *' |
5 | 5 |
|
6 | 6 | jobs: |
7 | | - close-issues: |
| 7 | + stale: |
8 | 8 | runs-on: ubuntu-latest |
9 | | - |
10 | 9 | steps: |
11 | | - - run: npm install @octokit/rest |
12 | | - - name: Close and Mark Stale Issues |
13 | | - uses: actions/github-script@v6 |
| 10 | + - uses: actions/stale@v8 |
14 | 11 | with: |
15 | | - script: | |
16 | | - const { Octokit } = require("@octokit/rest"); |
17 | | - const daysBeforeClosing = 180; |
18 | | - const staleLabel = 'stale'; |
19 | | - const token = '${{ secrets.GITHUB_TOKEN }}'; |
20 | | - const octokit = new Octokit({ auth: token }); |
21 | | -
|
22 | | - async function closeAndMarkStaleIssues() { |
23 | | - const { data: issues } = await octokit.rest.issues.listForRepo({ |
24 | | - owner: context.repo.owner, |
25 | | - repo: context.repo.repo, |
26 | | - state: 'open' |
27 | | - }); |
28 | | -
|
29 | | - const cutoffDate = new Date(); |
30 | | - cutoffDate.setDate(cutoffDate.getDate() - daysBeforeClosing); |
31 | | -
|
32 | | - for (const issue of issues) { |
33 | | - const issueDate = new Date(issue.updated_at); |
34 | | - if (issueDate < cutoffDate) { |
35 | | - await octokit.rest.issues.update({ |
36 | | - owner: context.repo.owner, |
37 | | - repo: context.repo.repo, |
38 | | - issue_number: issue.number, |
39 | | - state: 'closed' |
40 | | - }); |
41 | | -
|
42 | | - await octokit.rest.issues.addLabels({ |
43 | | - owner: context.repo.owner, |
44 | | - repo: context.repo.repo, |
45 | | - issue_number: issue.number, |
46 | | - labels: [staleLabel] |
47 | | - }); |
48 | | - } |
49 | | - } |
50 | | - } |
51 | | -
|
52 | | - closeAndMarkStaleIssues(); |
| 12 | + stale-issue-message: 'This issue is stale because it has been open 6 months with no activity. Remove stale label or comment or this will be closed in 5 days.' |
| 13 | + close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.' |
| 14 | + days-before-stale: 180 |
| 15 | + days-before-close: 5 |
0 commit comments