From 9ac0d84d7ff7f006df744d2eb22fc635ca01919b Mon Sep 17 00:00:00 2001 From: Anjaliavv51 <154777864+Anjaliavv51@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:35:32 +0530 Subject: [PATCH] code code for documentaion --- .github/workflows/add-gssoc-label-pr.yml | 43 ++++++++++++++++++------ .github/workflows/auto-label-issues.yml | 39 ++++++++++++++------- 2 files changed, 60 insertions(+), 22 deletions(-) diff --git a/.github/workflows/add-gssoc-label-pr.yml b/.github/workflows/add-gssoc-label-pr.yml index 4ef7d90..f835bfa 100644 --- a/.github/workflows/add-gssoc-label-pr.yml +++ b/.github/workflows/add-gssoc-label-pr.yml @@ -1,20 +1,43 @@ -name: Add GSSOC Label to PR - +name: Auto Label PRs on: pull_request: - types: [opened] + types: [opened, edited, synchronize] jobs: - add-label: + label_prs: runs-on: ubuntu-latest steps: - uses: actions/github-script@v6 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | - github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ["GSSOC"] - }) \ No newline at end of file + const pr = context.payload.pull_request; + const title = pr.title.toLowerCase(); + const body = pr.body ? pr.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, + owner: context.repo.owner, + repo: context.repo.name, + labels: labels + }); + } \ No newline at end of file diff --git a/.github/workflows/auto-label-issues.yml b/.github/workflows/auto-label-issues.yml index c3df2f4..47e4dbc 100644 --- a/.github/workflows/auto-label-issues.yml +++ b/.github/workflows/auto-label-issues.yml @@ -1,21 +1,36 @@ -name: Add GSSOC Label - +name: Auto Label Issues on: issues: - types: [opened] - + types: [opened, edited] jobs: - add-label: + label_issues: runs-on: ubuntu-latest steps: - uses: actions/github-script@v6 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | - github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ["gssoc"] - }) - \ No newline at end of file + 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, + owner: context.repo.owner, + repo: context.repo.name, + labels: labels + }); + } \ No newline at end of file