Skip to content

Commit

Permalink
Create duplicate-check.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
aditiverma-21 authored Nov 9, 2024
1 parent f998b46 commit 3c1e2da
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/duplicate-check.yml
Original file line number Diff line number Diff line change
@@ -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.`
});

0 comments on commit 3c1e2da

Please sign in to comment.