From df5a62c1aa5dcc086bb012182c9f4983bab3113b Mon Sep 17 00:00:00 2001 From: Anjaliavv51 <154777864+Anjaliavv51@users.noreply.github.com> Date: Mon, 29 Jul 2024 16:49:46 +0530 Subject: [PATCH] label code change #991 --- .github/PULL_REQUEST_TEMPLATE.md | 20 ++++----- .github/workflows/auto-label-issues.yml | 58 +++++++++++++++---------- .github/workflows/auto-label-pr.yml | 56 ++++++++++++++---------- 3 files changed, 75 insertions(+), 59 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index da6f7f2c..67a3aee1 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,32 +1,30 @@ + ## Description + -[Please include a brief description of the changes or features added] ## Related Issues -[Cite any related issue(s) this pull request addresses. If none, simply state “None”] + - Closes # ## Type of PR - -- [ ] Bug fix -- [ ] Feature enhancement -- [ ] Documentation update -- [ ] Other (specify): _______________ + +- [ ] () ## Screenshots / videos (if applicable) -[Attach any relevant screenshots or videos demonstrating the changes] + ## Checklist - + - [ ] I have gone through the [contributing guide](https://github.com/Anishkagupta04/RAPIDOC-HEALTHCARE-WEBSITE-/) - [ ] I have updated my branch and synced it with project `main` branch before making this PR - [ ] I have performed a self-review of my code - [ ] I have tested the changes thoroughly before submitting this pull request. - [ ] I have provided relevant issue numbers, screenshots, and videos after making the changes. - [ ] I have commented my code, particularly in hard-to-understand areas. - + ## Additional context: -[Include any additional information or context that might be helpful for reviewers.] + diff --git a/.github/workflows/auto-label-issues.yml b/.github/workflows/auto-label-issues.yml index 0dc1a2d5..73a20d7b 100644 --- a/.github/workflows/auto-label-issues.yml +++ b/.github/workflows/auto-label-issues.yml @@ -1,37 +1,47 @@ -name: Auto Label Issues +name: Auto Label Issue + on: issues: - types: [opened, edited] + types: [opened, reopened, edited] jobs: - label_issues: + label_issue: runs-on: ubuntu-latest + permissions: + issues: write steps: - - uses: actions/github-script@v6 + - name: Label Issue + uses: actions/github-script@v6 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | const issue = context.payload.issue; - const title = issue.title.toLowerCase(); - const body = issue.body.toLowerCase(); - const labels = []; - if (title.includes('gssoc') || body.includes('gssoc')) { - labels.push('GSSoC'); - } - if (title.includes('enhancement') || body.includes('enhancement')) { - labels.push('Enhancement'); - } - if (title.includes('bug') || body.includes('bug')) { - labels.push('Bug'); - } - if (title.includes('documentation') || body.includes('documentation')) { - labels.push('Documentation'); - } - if (labels.length > 0) { - github.rest.issues.addLabels({ - issue_number: context.issue.number, + const issueBody = issue.body ? issue.body.toLowerCase() : ''; + const issueTitle = issue.title.toLowerCase(); + + // Add gssoc label to all issues + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + labels: ['gssoc'] + }); + const addLabel = async (label) => { + await github.rest.issues.addLabels({ owner: context.repo.owner, - repo: context.repo.name, - labels: labels + repo: context.repo.repo, + issue_number: issue.number, + labels: [label] }); + }; + if (issueBody.includes('documentation') || issueTitle.includes('doc') || issueBody.includes('readme')) { + await addLabel('documentation'); + } + + if (issueBody.includes('feature') || issueBody.includes('enhancement') || issueTitle.includes('add') || issueTitle.includes('implement')) { + await addLabel('enhancement'); + + } + if (issueBody.includes('bug') || issueBody.includes('fix') || issueTitle.includes('fix') || issueTitle.includes('resolve')) { + await addLabel('bug'); } \ No newline at end of file diff --git a/.github/workflows/auto-label-pr.yml b/.github/workflows/auto-label-pr.yml index f835bfae..a858a7af 100644 --- a/.github/workflows/auto-label-pr.yml +++ b/.github/workflows/auto-label-pr.yml @@ -1,43 +1,51 @@ -name: Auto Label PRs + +name: Auto Label PR + on: pull_request: - types: [opened, edited, synchronize] + types: [opened, reopened, edited,synchronize] jobs: - label_prs: + label_pr: runs-on: ubuntu-latest + permissions: + pull-requests: write steps: - - uses: actions/github-script@v6 + - name: Label PR + uses: actions/github-script@v6 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | const pr = context.payload.pull_request; - const title = pr.title.toLowerCase(); - const body = pr.body ? pr.body.toLowerCase() : ''; - const labels = []; + // Add gssoc label to all PRs + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + labels: ['gssoc'] + }); - if (title.includes('gssoc') || body.includes('gssoc')) { - labels.push('GSSoC'); - } + const prBody = pr.body ? pr.body.toLowerCase() : ''; + const prTitle = pr.title.toLowerCase(); - if (title.includes('enhancement') || body.includes('enhancement')) { - labels.push('Enhancement'); - } + const addLabel = async (label) => { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + labels: [label] + }); + }; - if (title.includes('bug') || body.includes('bug')) { - labels.push('Bug'); + if (prBody.includes('documentation') || prTitle.includes('doc') || prBody.includes('readme')) { + await addLabel('documentation'); } - if (title.includes('documentation') || body.includes('documentation')) { - labels.push('Documentation'); + if (prBody.includes('feature') || prBody.includes('enhancement') || prTitle.includes('add') || prTitle.includes('implement')) { + await addLabel('enhancement'); } - if (labels.length > 0) { - github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.name, - labels: labels - }); + if (prBody.includes('bug') || prBody.includes('fix') || prTitle.includes('fix') || prTitle.includes('resolve')) { + await addLabel('bug'); } \ No newline at end of file