From d54dc6179a305d05d33ebb360410076dcf03a566 Mon Sep 17 00:00:00 2001
From: EliteMasterEric <ericmyllyoja@gmail.com>
Date: Wed, 18 Sep 2024 06:02:13 -0400
Subject: [PATCH 1/2] Add several new Github Actions for issue management

---
 .github/label-actions.yml                     | 23 ++++++++
 .github/workflows/label-actions.yml           | 29 +++++++++++
 .github/workflows/label-issue.yml             | 52 +++++++++++++++++++
 .../{labeler.yml => label-pull-request.yml}   |  2 +
 4 files changed, 106 insertions(+)
 create mode 100644 .github/label-actions.yml
 create mode 100644 .github/workflows/label-actions.yml
 create mode 100644 .github/workflows/label-issue.yml
 rename .github/workflows/{labeler.yml => label-pull-request.yml} (84%)

diff --git a/.github/label-actions.yml b/.github/label-actions.yml
new file mode 100644
index 000000000..00fb390aa
--- /dev/null
+++ b/.github/label-actions.yml
@@ -0,0 +1,23 @@
+# Configuration for Label Actions - https://github.com/dessant/label-actions
+
+# Automatically close issues and pull requests when the `status: duplicate` label is applied
+'status: duplicate':
+  issues:
+    # Post a comment
+    comment: >
+      This issue is a duplicate. Please direct all discussion to the original issue.
+    # Close the issue
+    close: true
+    # Remove other status labels
+    unlabel:
+      - 'status: pending triage'
+    # Set a close reason
+    close-reason: 'not planned'
+  prs:
+    # Post a comment
+    comment: >
+      This pull request is a duplicate. Please direct all discussion to the original pull request.
+    # Close the pull request
+    close: true
+    # Set a close reason
+    close-reason: 'not planned'
diff --git a/.github/workflows/label-actions.yml b/.github/workflows/label-actions.yml
new file mode 100644
index 000000000..bc4cf0add
--- /dev/null
+++ b/.github/workflows/label-actions.yml
@@ -0,0 +1,29 @@
+# Perform actions when labels are applied to issues, discussions, or pull requests
+# See .github/label-actions.yml
+name: 'Label Actions'
+
+on:
+  issues:
+    types:
+      - labeled
+      - unlabeled
+  pull_request_target:
+    types:
+      - labeled
+      - unlabeled
+  discussion:
+    types:
+      - labeled
+      - unlabeled
+
+permissions:
+  contents: read
+  issues: write
+  pull-requests: write
+  discussions: write
+
+jobs:
+  action:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: dessant/label-actions@v4
diff --git a/.github/workflows/label-issue.yml b/.github/workflows/label-issue.yml
new file mode 100644
index 000000000..eeb83350c
--- /dev/null
+++ b/.github/workflows/label-issue.yml
@@ -0,0 +1,52 @@
+name: "Issue Labeler"
+on:
+  issues:
+    types:
+      - opened
+      - reopened
+      - edited
+
+jobs:
+  # When an issue is opened, perform a similarity check for potential duplicates.
+  # If some are found, add a label and comment listing the potential duplicate issues.
+  potential-duplicate:
+    name: Detect potential duplicate issues
+    runs-on: ubuntu-latest
+    steps:
+      - uses: wow-actions/potential-duplicates@v1
+        with:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          # Issue title filter work with anymatch https://www.npmjs.com/package/anymatch.
+          # Any matched issue will stop detection immediately.
+          # You can specify multi filters in each line.
+          filter: ''
+          # Exclude keywords in title before detecting.
+          exclude: ''
+          # Label to set, when potential duplicates are detected.
+          label: 'potential duplicate'
+          # Get issues with state to compare. Supported state: 'all', 'closed', 'open'.
+          state: all
+          # If similarity is higher than this threshold([0,1]), issue will be marked as duplicate.
+          # Turn this up if the detection is too sensitive
+          threshold: 0.6
+          # Reactions to be add to comment when potential duplicates are detected.
+          # Available reactions: "-1", "+1", "confused", "laugh", "heart", "hooray", "rocket", "eyes"
+          # reactions: '-1'
+          # Comment to post when potential duplicates are detected.
+          comment: >
+            Potential duplicates: {{#issues}}
+              - [#{{ number }}] {{ title }} ({{ accuracy }}%)
+            {{/issues}}
+  # When an issue is opened, detect if it has an empty body or incomplete issue form.
+  # If it does, close the issue immediately.
+  empty-issues:
+    name: Close empty issues
+    runs-on: ubuntu-latest
+    steps:
+    - name: Run empty issues closer action
+      uses: rickstaa/empty-issues-closer-action@v1
+      env:
+        github_token: ${{ secrets.GITHUB_TOKEN }}
+      with:
+        close_comment: Closing this issue because it appears to be empty. Please update the issue for it to be reopened.
+        open_comment: Reopening this issue because the author provided more information.
diff --git a/.github/workflows/labeler.yml b/.github/workflows/label-pull-request.yml
similarity index 84%
rename from .github/workflows/labeler.yml
rename to .github/workflows/label-pull-request.yml
index a861af578..525e1b5a6 100644
--- a/.github/workflows/labeler.yml
+++ b/.github/workflows/label-pull-request.yml
@@ -3,6 +3,7 @@ on:
 - pull_request_target
 
 jobs:
+  # Apply labels to pull requests based on which files were edited
   labeler:
     permissions:
       contents: read
@@ -13,6 +14,7 @@ jobs:
       uses: actions/labeler@v5
       with:
         sync-labels: true
+  # Apply labels to pull requests based on how many lines were edited
   changed-lines-count-labeler:
     permissions:
       contents: read

From ba90a6abe04b15058a9c32a0ba1dd5338605c57a Mon Sep 17 00:00:00 2001
From: EliteMasterEric <ericmyllyoja@gmail.com>
Date: Wed, 18 Sep 2024 06:08:18 -0400
Subject: [PATCH 2/2] Add behavior when setting status: rejected

---
 .github/label-actions.yml | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/.github/label-actions.yml b/.github/label-actions.yml
index 00fb390aa..1234d1526 100644
--- a/.github/label-actions.yml
+++ b/.github/label-actions.yml
@@ -17,7 +17,28 @@
     # Post a comment
     comment: >
       This pull request is a duplicate. Please direct all discussion to the original pull request.
+    # Remove other status labels
+    unlabel:
+      - 'status: pending triage'
     # Close the pull request
     close: true
     # Set a close reason
     close-reason: 'not planned'
+
+'status: rejected':
+  issues:
+    # Close the issue
+    close: true
+    # Remove other status labels
+    unlabel:
+      - 'status: pending triage'
+    # Set a close reason
+    close-reason: 'not planned'
+  prs:
+    # Close the pull request
+    close: true
+    # Remove other status labels
+    unlabel:
+      - 'status: pending triage'
+    # Set a close reason
+    close-reason: 'not planned'