From 48ebfecf6a80469b9827119fc393ff0482bf0a0d Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 7 Jun 2023 15:50:24 -0700 Subject: [PATCH 1/4] Replace fabricbot with GHA for scheduled issue closing --- .github/fabricbot.json | 344 ----------------------------- .github/workflows/close-issues.yml | 40 ++++ 2 files changed, 40 insertions(+), 344 deletions(-) create mode 100644 .github/workflows/close-issues.yml diff --git a/.github/fabricbot.json b/.github/fabricbot.json index 70c26603f3446..34c3d255d4c25 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 0000000000000..e07978fc01de2 --- /dev/null +++ b/.github/workflows/close-issues.yml @@ -0,0 +1,40 @@ +name: Close issues + +on: + schedule: + - cron: '0 1 * * *' + workflow_dispatch: + +permissions: + contents: read + issues: write + +# 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: + build: + runs-on: ubuntu-latest + if: github.repository == 'microsoft/TypeScript' + + 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 "External" + close_issues "Working as Intended" + close_issues "Question" + From 2e58b830c36b7f42f022a008bc8fd7612ed55f16 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 7 Jun 2023 15:51:29 -0700 Subject: [PATCH 2/4] newline --- .github/workflows/close-issues.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/close-issues.yml b/.github/workflows/close-issues.yml index e07978fc01de2..939550d8b1abc 100644 --- a/.github/workflows/close-issues.yml +++ b/.github/workflows/close-issues.yml @@ -37,4 +37,3 @@ jobs: close_issues "External" close_issues "Working as Intended" close_issues "Question" - From 5cc42521f692e7ce2354f5f789b497a4e550e1b6 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 7 Jun 2023 15:53:22 -0700 Subject: [PATCH 3/4] Small fixups --- .github/workflows/close-issues.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/close-issues.yml b/.github/workflows/close-issues.yml index 939550d8b1abc..b402c226e294b 100644 --- a/.github/workflows/close-issues.yml +++ b/.github/workflows/close-issues.yml @@ -7,7 +7,6 @@ on: permissions: contents: read - issues: write # 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 @@ -16,9 +15,12 @@ defaults: shell: bash jobs: - build: + 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 From df99679626d58a64d452da96a4b6489ab302a7fb Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 7 Jun 2023 16:08:44 -0700 Subject: [PATCH 4/4] Update .github/workflows/close-issues.yml Co-authored-by: Ryan Cavanaugh --- .github/workflows/close-issues.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/close-issues.yml b/.github/workflows/close-issues.yml index b402c226e294b..168d602f95e89 100644 --- a/.github/workflows/close-issues.yml +++ b/.github/workflows/close-issues.yml @@ -36,6 +36,8 @@ jobs: } close_issues "Duplicate" + close_issues "Unactionable" + close_issues "Not a Defect" close_issues "External" close_issues "Working as Intended" close_issues "Question"