diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-04-18 19:39:27 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-04-18 19:39:27 -0400 |
commit | f9601f70b1454fca0fd908d1942038f3f705b665 (patch) | |
tree | 9f19a6703b50c9e8e5153af42e1201f7195029ea | |
parent | 962315a5fc059f43b02a120aed5bb53fcfdc2641 (diff) | |
download | kutter-f9601f70b1454fca0fd908d1942038f3f705b665.tar.gz kutter-f9601f70b1454fca0fd908d1942038f3f705b665.tar.xz kutter-f9601f70b1454fca0fd908d1942038f3f705b665.zip |
github: Add close-invalid-bot.yaml
The generic stale issue tool wont close an issue that has comments
after the initial invalid message. Add a bot to close invalid issues.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | .github/workflows/close-invalid-bot.yaml | 33 | ||||
-rw-r--r-- | .github/workflows/stale-issue-bot.yaml | 11 |
2 files changed, 33 insertions, 11 deletions
diff --git a/.github/workflows/close-invalid-bot.yaml b/.github/workflows/close-invalid-bot.yaml new file mode 100644 index 00000000..6fb95966 --- /dev/null +++ b/.github/workflows/close-invalid-bot.yaml @@ -0,0 +1,33 @@ +# Close issues marked as invalid +name: "Close issues marked as invalid" +on: + schedule: + - cron: '0 */6 * * * *' +jobs: + close_invalid: + 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: 'invalid', + per_page: 100, + page: 1 + }); + const expireMillis = 1000 * 60 * 60 * 36; + 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; + await github.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + state: 'closed' + }); + } diff --git a/.github/workflows/stale-issue-bot.yaml b/.github/workflows/stale-issue-bot.yaml index 7a6421d0..96b5d3d0 100644 --- a/.github/workflows/stale-issue-bot.yaml +++ b/.github/workflows/stale-issue-bot.yaml @@ -29,14 +29,3 @@ jobs: exempt-issue-labels: 'enhancement,bug' days-before-stale: 35 days-before-close: 7 - invalid: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-label: invalid - stale-pr-label: invalid - days-before-stale: -1 - days-before-close: 2 - remove-stale-when-updated: false |