diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-05-13 22:49:55 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-05-13 22:55:43 -0400 |
commit | 7b170d8c3dee752bb8c6ee8de730fc0bf6290c5e (patch) | |
tree | ce92de3baf924ee41334cf9aa40d1610f1236bf4 /.github | |
parent | 49937f6281e21265cb3d75e3e57b28275b5cf659 (diff) | |
download | kutter-7b170d8c3dee752bb8c6ee8de730fc0bf6290c5e.tar.gz kutter-7b170d8c3dee752bb8c6ee8de730fc0bf6290c5e.tar.xz kutter-7b170d8c3dee752bb8c6ee8de730fc0bf6290c5e.zip |
github: Automatically close resolved issues after one week of inactivity
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/stale-issue-bot.yaml | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/.github/workflows/stale-issue-bot.yaml b/.github/workflows/stale-issue-bot.yaml index 96b5d3d0..1d6534fa 100644 --- a/.github/workflows/stale-issue-bot.yaml +++ b/.github/workflows/stale-issue-bot.yaml @@ -29,3 +29,43 @@ jobs: exempt-issue-labels: 'enhancement,bug' days-before-stale: 35 days-before-close: 7 + close_resolved: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v3 + with: + script: | + const issues = await github.issues.listForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + labels: 'resolved', + per_page: 100, + page: 1 + }); + const expireMillis = 1000 * 60 * 60 * 24 * 7; + const curtime = new Date().getTime(); + for (var issue of issues.data.values()) { + const updatetime = new Date(issue.updated_at).getTime(); + if (curtime < updatetime + expireMillis) + continue; + msg = "This ticket is being closed because the underlying issue" + + " is now thought to be resolved." + + "\n\n" + + "Best regards,\n" + + "~ Your friendly GitIssueBot" + + "\n\n" + + "PS: I'm just an automated script, not a human being."; + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + body: msg + }); + await github.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + state: 'closed' + }); + } |