From 74810dee588b722e4ff092f186b415d5ac677112 Mon Sep 17 00:00:00 2001 From: Anjaliavv51 <154777864+Anjaliavv51@users.noreply.github.com> Date: Tue, 30 Jul 2024 21:27:38 +0530 Subject: [PATCH 1/5] =?UTF-8?q?=E2=9C=A8[Feature=20Request]:=20Automatic?= =?UTF-8?q?=20assign?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #1070 --- .github/workflows/assignlabel.yml | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/assignlabel.yml diff --git a/.github/workflows/assignlabel.yml b/.github/workflows/assignlabel.yml new file mode 100644 index 00000000..0d8706d6 --- /dev/null +++ b/.github/workflows/assignlabel.yml @@ -0,0 +1,56 @@ +name: Assign Issue to Creator + +on: + issue_comment: + types: [created] + +jobs: + assign-issue: + runs-on: ubuntu-latest + if: contains(github.event.comment.body, '/a') + steps: + - name: Check commenter permissions + id: check-permissions + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const { owner, repo } = context.repo; + const commenter = context.payload.comment.user.login; + + const { data: repoPermission } = await github.rest.repos.getCollaboratorPermissionLevel({ + owner, + repo, + username: commenter, + }); + + const allowedPermissions = ['admin', 'maintain', 'write']; + const hasPermission = allowedPermissions.includes(repoPermission.permission); + + console.log(`Commenter ${commenter} has permission: ${hasPermission}`); + return hasPermission; + - name: Assign issue to creator + if: steps.check-permissions.outputs.result == 'true' + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const { owner, repo } = context.repo; + const issue_number = context.issue.number; + + const { data: issue } = await github.rest.issues.get({ + owner, + repo, + issue_number, + }); + + const creator = issue.user.login; + + await github.rest.issues.addAssignees({ + owner, + repo, + issue_number, + assignees: [creator], + }); + + console.log(`Assigned issue #${issue_number} to creator ${creator}`); \ No newline at end of file From e17d7142535703b1b2a3a470d723848a4d99a218 Mon Sep 17 00:00:00 2001 From: Anjaliavv51 <154777864+Anjaliavv51@users.noreply.github.com> Date: Tue, 30 Jul 2024 21:33:26 +0530 Subject: [PATCH 2/5] updated Automatic pr label #1070 --- .github/workflows/auto-label-pr.yml | 62 +++++++++++++++-------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/.github/workflows/auto-label-pr.yml b/.github/workflows/auto-label-pr.yml index a858a7af..25824c74 100644 --- a/.github/workflows/auto-label-pr.yml +++ b/.github/workflows/auto-label-pr.yml @@ -1,51 +1,53 @@ - -name: Auto Label PR +name: Auto Label PRs on: pull_request: - types: [opened, reopened, edited,synchronize] + types: [opened, edited] jobs: label_pr: runs-on: ubuntu-latest - permissions: - pull-requests: write steps: - - name: Label PR + - uses: actions/labeler@v4 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + configuration-path: .github/labeler.yml + + - name: Add GSSOC label uses: actions/github-script@v6 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | - const pr = context.payload.pull_request; - - // Add gssoc label to all PRs - await github.rest.issues.addLabels({ + github.rest.issues.addLabels({ + issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - issue_number: pr.number, labels: ['gssoc'] - }); + }) + + - name: Add additional labels based on title + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const title = context.payload.pull_request.title.toLowerCase(); + const labelsToAdd = []; - const prBody = pr.body ? pr.body.toLowerCase() : ''; - const prTitle = pr.title.toLowerCase(); + if (title.includes('documentation')) { + labelsToAdd.push('documentation'); + } + if (title.includes('feature')) { + labelsToAdd.push('feature'); + } + if (title.includes('bug')) { + labelsToAdd.push('bug'); + } - const addLabel = async (label) => { - await github.rest.issues.addLabels({ + if (labelsToAdd.length > 0) { + github.rest.issues.addLabels({ + issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - issue_number: pr.number, - labels: [label] + labels: labelsToAdd }); - }; - - if (prBody.includes('documentation') || prTitle.includes('doc') || prBody.includes('readme')) { - await addLabel('documentation'); - } - - if (prBody.includes('feature') || prBody.includes('enhancement') || prTitle.includes('add') || prTitle.includes('implement')) { - await addLabel('enhancement'); - } - - if (prBody.includes('bug') || prBody.includes('fix') || prTitle.includes('fix') || prTitle.includes('resolve')) { - await addLabel('bug'); } \ No newline at end of file From 7140d473d6072e0bd99ca0f1adbbff1ea13b2510 Mon Sep 17 00:00:00 2001 From: Anjaliavv51 <154777864+Anjaliavv51@users.noreply.github.com> Date: Tue, 30 Jul 2024 21:37:47 +0530 Subject: [PATCH 3/5] update in PR Template #1070 --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 67a3aee1..d80c2d98 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ ## Description - + ## Related Issues From cdbaa82916db4250616d449c978bc6c7fd4a1805 Mon Sep 17 00:00:00 2001 From: Vamshi Maskuri <117595548+varshith257@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:55:42 +0530 Subject: [PATCH 4/5] Update .github/workflows/assignlabel.yml --- .github/workflows/assignlabel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/assignlabel.yml b/.github/workflows/assignlabel.yml index 0d8706d6..905ded74 100644 --- a/.github/workflows/assignlabel.yml +++ b/.github/workflows/assignlabel.yml @@ -7,7 +7,7 @@ on: jobs: assign-issue: runs-on: ubuntu-latest - if: contains(github.event.comment.body, '/a') + if: contains(github.event.comment.body, '/assign') steps: - name: Check commenter permissions id: check-permissions From f8a95318ec0d04612074ff6672ea4fa4d394c72f Mon Sep 17 00:00:00 2001 From: Vamshi Maskuri <117595548+varshith257@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:57:09 +0530 Subject: [PATCH 5/5] Update .github/workflows/assignlabel.yml --- .github/workflows/assignlabel.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/assignlabel.yml b/.github/workflows/assignlabel.yml index 905ded74..831dc8db 100644 --- a/.github/workflows/assignlabel.yml +++ b/.github/workflows/assignlabel.yml @@ -27,7 +27,6 @@ jobs: const allowedPermissions = ['admin', 'maintain', 'write']; const hasPermission = allowedPermissions.includes(repoPermission.permission); - console.log(`Commenter ${commenter} has permission: ${hasPermission}`); return hasPermission; - name: Assign issue to creator if: steps.check-permissions.outputs.result == 'true'