From 792621aafa0a8e5394ba76933b94db4b50797f4b Mon Sep 17 00:00:00 2001 From: Lakshmi Pavananjali <154777864+Anjaliavv51@users.noreply.github.com> Date: Mon, 29 Jul 2024 15:26:11 +0530 Subject: [PATCH 1/2] Update add-gssoc-label-pr.yml --- .github/workflows/add-gssoc-label-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add-gssoc-label-pr.yml b/.github/workflows/add-gssoc-label-pr.yml index 8c85280..7d3dcd2 100644 --- a/.github/workflows/add-gssoc-label-pr.yml +++ b/.github/workflows/add-gssoc-label-pr.yml @@ -2,7 +2,7 @@ name: Auto Label PR on: pull_request: - types: [opened, reopened, synchronize,edited] + types: [opened, reopened, synchronize] jobs: label_pr: From b6446748e257a61f6a254076144bddcf4ddcf30f Mon Sep 17 00:00:00 2001 From: Lakshmi Pavananjali <154777864+Anjaliavv51@users.noreply.github.com> Date: Mon, 29 Jul 2024 15:27:53 +0530 Subject: [PATCH 2/2] Update auto-label-issues.yml --- .github/workflows/auto-label-issues.yml | 68 ++++++++++++------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/.github/workflows/auto-label-issues.yml b/.github/workflows/auto-label-issues.yml index 7cb387d..7e5a3d6 100644 --- a/.github/workflows/auto-label-issues.yml +++ b/.github/workflows/auto-label-issues.yml @@ -1,56 +1,52 @@ -name: Auto Label Issues +name: Auto Label Issue on: issues: - types: [opened, reopened,edited] + types: [opened, reopened, edited] jobs: - auto-label: + label_issue: runs-on: ubuntu-latest + permissions: + issues: write steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Apply GSSoC label - 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.name, - labels: ['GSSoC'] - }) - - - name: Categorize issue + - 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 issueBody = issue.body ? issue.body.toLowerCase() : ''; + const issueTitle = issue.title.toLowerCase(); - let labels = []; + // 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'] + }); - if (title.includes('doc') || body.includes('doc') || title.includes('readme') || body.includes('readme')) { - labels.push('documentation'); - } + const addLabel = async (label) => { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + labels: [label] + }); + }; - if (title.includes('feature') || body.includes('feature') || title.includes('enhance') || body.includes('enhance')) { - labels.push('enhancement'); + // Check for documentation changes + if (issueBody.includes('documentation') || issueTitle.includes('doc') || issueBody.includes('readme')) { + await addLabel('documentation'); } - if (title.includes('bug') || body.includes('bug') || title.includes('fix') || body.includes('fix')) { - labels.push('bug'); + // Check for enhancements + if (issueBody.includes('feature') || issueBody.includes('enhancement') || issueTitle.includes('add') || issueTitle.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 - }); + // Check for bugs + if (issueBody.includes('bug') || issueBody.includes('fix') || issueTitle.includes('fix') || issueTitle.includes('resolve')) { + await addLabel('bug'); }