Migrate to the Locker GitHub action for locking closed/stale issues/PRs (#4417)
authorJeff Handley <jeffhandley@users.noreply.github.com>
Thu, 7 Dec 2023 21:39:42 +0000 (13:39 -0800)
committerGitHub <noreply@github.com>
Thu, 7 Dec 2023 21:39:42 +0000 (16:39 -0500)
This migrates away from the FabricBot implementation of a scheduled
search over closed issues and adopts the
[Locker](https://github.com/microsoft/vscode-github-triage-actions/?tab=readme-ov-file#locker)
GitHub action authored by the VS Code team.

The updated fabricbot.json was generated via
https://github.com/dotnet/fabricbot-config/pull/83. The workflow file
was implemented and tested at
https://github.com/dotnet/fabricbot-config/blob/main/.github/workflows/locker.yml.

Since this workflow uses the actions/checkout action, we need to ensure
the following GitHub Actions settings are enabled:

1. Allow enterprise, and select non-enterprise, actions and reusable
workflows
2. Allow actions created by GitHub

/cc @wtgodbe

.github/fabricbot.json
.github/workflows/locker.yml [new file with mode: 0644]

index 2e190edba06f20fd707b0da8cd81da5e1fd68d6b..fdc12a789c6b6185ef22aafbf2e2bb299b9bb290 100644 (file)
         ]
       }
     },
-    {
-      "taskType": "scheduled",
-      "capabilityId": "ScheduledSearch",
-      "subCapability": "ScheduledSearch",
-      "version": "1.1",
-      "config": {
-        "frequency": [
-          {
-            "weekDay": 0,
-            "hours": [
-              1,
-              4,
-              7,
-              10,
-              13,
-              16,
-              19,
-              22
-            ],
-            "timezoneOffset": -8
-          },
-          {
-            "weekDay": 1,
-            "hours": [
-              1,
-              4,
-              7,
-              10,
-              13,
-              16,
-              19,
-              22
-            ],
-            "timezoneOffset": -8
-          },
-          {
-            "weekDay": 2,
-            "hours": [
-              1,
-              4,
-              7,
-              10,
-              13,
-              16,
-              19,
-              22
-            ],
-            "timezoneOffset": -8
-          },
-          {
-            "weekDay": 3,
-            "hours": [
-              1,
-              4,
-              7,
-              10,
-              13,
-              16,
-              19,
-              22
-            ],
-            "timezoneOffset": -8
-          },
-          {
-            "weekDay": 4,
-            "hours": [
-              1,
-              4,
-              7,
-              10,
-              13,
-              16,
-              19,
-              22
-            ],
-            "timezoneOffset": -8
-          },
-          {
-            "weekDay": 5,
-            "hours": [
-              1,
-              4,
-              7,
-              10,
-              13,
-              16,
-              19,
-              22
-            ],
-            "timezoneOffset": -8
-          },
-          {
-            "weekDay": 6,
-            "hours": [
-              1,
-              4,
-              7,
-              10,
-              13,
-              16,
-              19,
-              22
-            ],
-            "timezoneOffset": -8
-          }
-        ],
-        "searchTerms": [
-          {
-            "name": "isClosed",
-            "parameters": {}
-          },
-          {
-            "name": "noActivitySince",
-            "parameters": {
-              "days": 30
-            }
-          },
-          {
-            "name": "isUnlocked",
-            "parameters": {}
-          },
-          {
-            "name": "isIssue",
-            "parameters": {}
-          },
-          {
-            "name": "noLabel",
-            "parameters": {
-              "label": "Bot: Do Not Lock"
-            }
-          }
-        ],
-        "taskName": "[Closed Issue Management] Lock issues closed without activity for over 30 days",
-        "actions": [
-          {
-            "name": "lockIssue",
-            "parameters": {
-              "reason": "resolved"
-            }
-          }
-        ]
-      }
-    }
   ],
   "userGroups": []
 }
diff --git a/.github/workflows/locker.yml b/.github/workflows/locker.yml
new file mode 100644 (file)
index 0000000..0e7b771
--- /dev/null
@@ -0,0 +1,36 @@
+name: Locker - Lock stale issues and PRs
+on:
+  schedule:
+    - cron: '0 9 * * *' # Once per day, early morning PT
+
+  workflow_dispatch:
+    # Manual triggering through the GitHub UI, API, or CLI
+    inputs:
+      daysSinceClose:
+        required: true
+        default: "30"
+      daysSinceUpdate:
+        required: true
+        default: "30"
+
+permissions:
+  issues: write
+  pull-requests: write
+
+jobs:
+  main:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout Actions
+        uses: actions/checkout@v4
+        with:
+          repository: "microsoft/vscode-github-triage-actions"
+          path: ./actions
+          ref: cd16cd2aad6ba2da74bb6c6f7293adddd579a90e # locker action commit sha
+      - name: Install Actions
+        run: npm install --production --prefix ./actions
+      - name: Run Locker
+        uses: ./actions/locker
+        with:
+          daysSinceClose:  ${{ fromJson(inputs.daysSinceClose  || 30) }}
+          daysSinceUpdate: ${{ fromJson(inputs.daysSinceUpdate || 30) }}