From e8a1dbba2298a5d2b031be6463bd6c1a32eeea10 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 7 Jun 2023 20:29:15 -0700 Subject: [PATCH] Replace fabricbot with GHA for scheduled issue closing (#54566) Co-authored-by: Ryan Cavanaugh --- .github/fabricbot.json | 344 ----------------------------- .github/workflows/close-issues.yml | 43 ++++ 2 files changed, 43 insertions(+), 344 deletions(-) create mode 100644 .github/workflows/close-issues.yml diff --git a/.github/fabricbot.json b/.github/fabricbot.json index 70c26603f34..34c3d255d4c 100644 --- a/.github/fabricbot.json +++ b/.github/fabricbot.json @@ -108,177 +108,6 @@ ] } }, - { - "taskType": "scheduled", - "capabilityId": "ScheduledSearch", - "subCapability": "ScheduledSearch", - "version": "1.0", - "config": { - "frequency": [ - { - "weekDay": 0, - "hours": [ - 18 - ] - }, - { - "weekDay": 1, - "hours": [ - 18 - ] - }, - { - "weekDay": 2, - "hours": [ - 18 - ] - }, - { - "weekDay": 3, - "hours": [ - 18 - ] - }, - { - "weekDay": 4, - "hours": [ - 18 - ] - }, - { - "weekDay": 5, - "hours": [ - 18 - ] - }, - { - "weekDay": 6, - "hours": [ - 18 - ] - } - ], - "searchTerms": [ - { - "name": "noActivitySince", - "parameters": { - "days": 2 - } - }, - { - "name": "hasLabel", - "parameters": { - "label": "Duplicate" - } - }, - { - "name": "isOpen", - "parameters": {} - } - ], - "taskName": "Close Duplicates", - "actions": [ - { - "name": "closeIssue", - "parameters": {} - }, - { - "name": "addReply", - "parameters": { - "comment": "This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes." - } - } - ] - } - }, - { - "taskType": "scheduled", - "capabilityId": "ScheduledSearch", - "subCapability": "ScheduledSearch", - "version": "1.0", - "config": { - "taskName": "Close Externals", - "frequency": [ - { - "weekDay": 0, - "hours": [ - 10 - ], - "restrictions": [ - { - "name": "" - } - ] - }, - { - "weekDay": 1, - "hours": [ - 10 - ] - }, - { - "weekDay": 2, - "hours": [ - 10 - ] - }, - { - "weekDay": 3, - "hours": [ - 10 - ] - }, - { - "weekDay": 4, - "hours": [ - 10 - ] - }, - { - "weekDay": 5, - "hours": [ - 10 - ] - }, - { - "weekDay": 6, - "hours": [ - 10 - ] - } - ], - "searchTerms": [ - { - "name": "hasLabel", - "parameters": { - "label": "External" - } - }, - { - "name": "isOpen", - "parameters": {} - }, - { - "name": "noActivitySince", - "parameters": { - "days": 2 - } - } - ], - "actions": [ - { - "name": "closeIssue", - "parameters": {} - }, - { - "name": "addReply", - "parameters": { - "comment": "This issue has been marked as 'External' and has seen no recent activity. It has been automatically closed for house-keeping purposes." - } - } - ] - } - }, { "taskType": "trigger", "capabilityId": "IssueResponder", @@ -372,89 +201,6 @@ ] } }, - { - "taskType": "scheduled", - "capabilityId": "ScheduledSearch", - "subCapability": "ScheduledSearch", - "version": "1.0", - "config": { - "taskName": "Close Working as Intended", - "frequency": [ - { - "weekDay": 0, - "hours": [ - 20 - ] - }, - { - "weekDay": 1, - "hours": [ - 20 - ] - }, - { - "weekDay": 2, - "hours": [ - 20 - ] - }, - { - "weekDay": 3, - "hours": [ - 20 - ] - }, - { - "weekDay": 4, - "hours": [ - 20 - ] - }, - { - "weekDay": 5, - "hours": [ - 20 - ] - }, - { - "weekDay": 6, - "hours": [ - 20 - ] - } - ], - "searchTerms": [ - { - "name": "hasLabel", - "parameters": { - "label": "Working as Intended" - } - }, - { - "name": "isOpen", - "parameters": {} - }, - { - "name": "noActivitySince", - "parameters": { - "days": 2 - } - } - ], - "actions": [ - { - "name": "addReply", - "parameters": { - "comment": "This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes." - } - }, - { - "name": "closeIssue", - "parameters": {} - } - ] - } - }, { "taskType": "trigger", "capabilityId": "IssueResponder", @@ -494,96 +240,6 @@ }, "disabled": true }, - { - "taskType": "scheduled", - "capabilityId": "ScheduledSearch", - "subCapability": "ScheduledSearch", - "version": "1.1", - "config": { - "taskName": "Close Questions", - "frequency": [ - { - "weekDay": 0, - "hours": [ - 0, - 12 - ] - }, - { - "weekDay": 1, - "hours": [ - 0, - 12 - ] - }, - { - "weekDay": 2, - "hours": [ - 0, - 12 - ] - }, - { - "weekDay": 3, - "hours": [ - 0, - 12 - ] - }, - { - "weekDay": 4, - "hours": [ - 0, - 12 - ] - }, - { - "weekDay": 5, - "hours": [ - 0, - 12 - ] - }, - { - "weekDay": 6, - "hours": [ - 0, - 12 - ] - } - ], - "searchTerms": [ - { - "name": "hasLabel", - "parameters": { - "label": "Question" - } - }, - { - "name": "isOpen", - "parameters": {} - }, - { - "name": "noActivitySince", - "parameters": { - "days": 2 - } - } - ], - "actions": [ - { - "name": "closeIssue", - "parameters": {} - }, - { - "name": "addReply", - "parameters": { - "comment": "This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to [stackoverflow](https://stackoverflow.com/questions/tagged/typescript) or the [TypeScript Discord community](https://discord.gg/typescript)." - } - } - ] - } - }, { "taskType": "trigger", "capabilityId": "IssueResponder", diff --git a/.github/workflows/close-issues.yml b/.github/workflows/close-issues.yml new file mode 100644 index 00000000000..168d602f95e --- /dev/null +++ b/.github/workflows/close-issues.yml @@ -0,0 +1,43 @@ +name: Close issues + +on: + schedule: + - cron: '0 1 * * *' + workflow_dispatch: + +permissions: + contents: read + +# Ensure scripts are run with pipefail. See: +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference +defaults: + run: + shell: bash + +jobs: + close-issues: + runs-on: ubuntu-latest + if: github.repository == 'microsoft/TypeScript' + permissions: + contents: read # Apparently required to create issues + issues: write + + steps: + - name: Close issues + run: | + DATE=$(date --date='2 days ago' --iso-8601) + + close_issues() { + echo "Closing issues marked as '$1'." + for issue in $(gh issue list --label "$1" --repo ${{ github.repository }} --state open --search "updated:<$DATE" --json number --jq '.[].number'); do + echo "Closing https://github.com/${{ github.repository }}/issues/$issue" + gh issue close $issue --reason "not planned" --comment "This issue has been marked as '$1' and has seen no recent activity. It has been automatically closed for house-keeping purposes." + done + } + + close_issues "Duplicate" + close_issues "Unactionable" + close_issues "Not a Defect" + close_issues "External" + close_issues "Working as Intended" + close_issues "Question"