diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-08-17 12:55:15 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-08-17 12:55:15 -0400 |
commit | f2dd6774917f69a0b6b6270a680ccce15c6f3c8c (patch) | |
tree | 06928c36cf61bb1c54d2d6f21929565c8b65887a /.github | |
parent | dd1b1f496c6a4bdd394fa5f8665613b719d5c11e (diff) | |
download | kutter-f2dd6774917f69a0b6b6270a680ccce15c6f3c8c.tar.gz kutter-f2dd6774917f69a0b6b6270a680ccce15c6f3c8c.tar.xz kutter-f2dd6774917f69a0b6b6270a680ccce15c6f3c8c.zip |
workflows: Add script to manage "not mainline" and "pending feedback" PRs
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/stale-issue-bot.yaml | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/.github/workflows/stale-issue-bot.yaml b/.github/workflows/stale-issue-bot.yaml index 470b4812..284c826b 100644 --- a/.github/workflows/stale-issue-bot.yaml +++ b/.github/workflows/stale-issue-bot.yaml @@ -99,3 +99,93 @@ jobs: state: 'closed' }); } + # Close PRs marked with "not mainline" label + close_not_mainline: + 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: 'not mainline', + 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 PR is being closed because it is currently not" + + " considered a good match for the master Klipper" + + " repository." + + "\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' + }); + } + # Mark (and close) PRs with "pending feedback" for 3+ weeks + mark_inactive: + 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: 'pending feedback', + per_page: 100, + page: 1 + }); + const expireMillis = 1000 * 60 * 60 * 24 * 21; + 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 = "It looks like this GitHub Pull Request has become" + + " inactive. If there are any further updates, you can" + " " add a comment here or open a new ticket." + + "\n\n" + + "Best regards,\n" + + "~ Your friendly GitIssueBot" + + "\n\n" + + "PS: I'm just an automated script, not a human being."; + await github.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + labels: ['inactive'] + }); + 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' + }); + } |