From 62c4d0cf866526be486a6ed931473bfb55f73a57 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 14 Jan 2024 07:07:14 +0100 Subject: [PATCH 1/4] new command --- .github/workflows/cleanup.yml | 1 + .github/workflows/close-duplicates.yml | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 .github/workflows/close-duplicates.yml diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml index b458fb0489..e4280b3b4b 100644 --- a/.github/workflows/cleanup.yml +++ b/.github/workflows/cleanup.yml @@ -56,6 +56,7 @@ jobs: const workflows = [ 'cleanup.yml', + 'close-duplicates.yml', 'closed-issues.yml', 'debug-info-actions.yml', 'depsreview.yml', diff --git a/.github/workflows/close-duplicates.yml b/.github/workflows/close-duplicates.yml new file mode 100644 index 0000000000..a505942c64 --- /dev/null +++ b/.github/workflows/close-duplicates.yml @@ -0,0 +1,25 @@ +name: "Issues - Command to close duplicate issues" + +# the workflow to execute on is comments that are newly created +on: + issue_comment: + types: [created] + +permissions: + issues: write + checks: read + +jobs: + close_duplicates: + runs-on: ubuntu-latest + steps: + - uses: github/command@v1.1.0 + id: command + with: + command: ".duplicate" + - name: reply + if: ${{ steps.command.outputs.continue == 'true' }} + run: | + gh issue comment "$NUMBER" --body "Hi there!\n\nThis is an automatic reply. `Share and enjoy`.\n\nThis issue is probably a duplicate of #${{ steps.command.outputs.params }}. Please refer to that issue for support.\n\nThank you for your contribution." + gh issue close "$NUMBER" --reason completed + gh issue lock "$NUMBER" From ae31041f7f1c3829a78c27cdf8fe8fca448d9e14 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 14 Jan 2024 07:11:39 +0100 Subject: [PATCH 2/4] Add context --- .github/workflows/close-duplicates.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/close-duplicates.yml b/.github/workflows/close-duplicates.yml index a505942c64..b2b26d9f9e 100644 --- a/.github/workflows/close-duplicates.yml +++ b/.github/workflows/close-duplicates.yml @@ -16,6 +16,7 @@ jobs: - uses: github/command@v1.1.0 id: command with: + allowed_contexts: "issue" command: ".duplicate" - name: reply if: ${{ steps.command.outputs.continue == 'true' }} From d614519ee7f9e52b83be5363b5ffd558745be4cb Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 14 Jan 2024 07:12:47 +0100 Subject: [PATCH 3/4] Add necessary params. --- .github/workflows/close-duplicates.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/close-duplicates.yml b/.github/workflows/close-duplicates.yml index b2b26d9f9e..438778e5d5 100644 --- a/.github/workflows/close-duplicates.yml +++ b/.github/workflows/close-duplicates.yml @@ -24,3 +24,7 @@ jobs: gh issue comment "$NUMBER" --body "Hi there!\n\nThis is an automatic reply. `Share and enjoy`.\n\nThis issue is probably a duplicate of #${{ steps.command.outputs.params }}. Please refer to that issue for support.\n\nThank you for your contribution." gh issue close "$NUMBER" --reason completed gh issue lock "$NUMBER" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.issue.number }} From 577824930f3b5c903acee0fc3663b78d071dd4e1 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 14 Jan 2024 07:15:08 +0100 Subject: [PATCH 4/4] Attempt at newline. --- .github/workflows/close-duplicates.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/close-duplicates.yml b/.github/workflows/close-duplicates.yml index 438778e5d5..df8f1a838b 100644 --- a/.github/workflows/close-duplicates.yml +++ b/.github/workflows/close-duplicates.yml @@ -21,7 +21,16 @@ jobs: - name: reply if: ${{ steps.command.outputs.continue == 'true' }} run: | - gh issue comment "$NUMBER" --body "Hi there!\n\nThis is an automatic reply. `Share and enjoy`.\n\nThis issue is probably a duplicate of #${{ steps.command.outputs.params }}. Please refer to that issue for support.\n\nThank you for your contribution." + gh issue comment "$NUMBER" --body 'Hi there! + + This is an automatic reply. `Share and enjoy`. + + This issue is probably a duplicate of issue #${{ steps.command.outputs.params }}. This issue probably refers to the same bug or feature request as your issue. + + Please refer to that issue for support. + + Thank you for your contribution.' + gh issue close "$NUMBER" --reason completed gh issue lock "$NUMBER" env: