From 3c1e2da3679a3aa94d5768497fd4f006a1db76b2 Mon Sep 17 00:00:00 2001 From: Aditi Verma Date: Sat, 9 Nov 2024 23:17:38 +0530 Subject: [PATCH] Create duplicate-check.yml --- .github/workflows/duplicate-check.yml | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/duplicate-check.yml diff --git a/.github/workflows/duplicate-check.yml b/.github/workflows/duplicate-check.yml new file mode 100644 index 0000000..5b89a9c --- /dev/null +++ b/.github/workflows/duplicate-check.yml @@ -0,0 +1,42 @@ +name: Duplicate Issue Checker + +on: + issues: + types: [opened] + +permissions: + issues: write + contents: read + +jobs: + check_duplicates: + runs-on: ubuntu-latest + steps: + - name: Check for Duplicates + uses: actions/issue-labeler@v1 + id: duplicate_check + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + config-path: .github/duplicate-issue-config.yml + + - name: Close and Comment on Duplicate + if: steps.duplicate_check.outputs.is_duplicate == 'true' + uses: actions/github-script@v6 + with: + script: | + const issue_number = context.payload.issue.number; + const duplicate_issue_number = steps.duplicate_check.outputs.duplicate_issue_number; + + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + state: 'closed' + }); + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: `This issue appears to be a duplicate of #${duplicate_issue_number}. Please follow updates on the original issue.` + });