You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/06/27 20:32:38 UTC

[GitHub] [beam] damccorm opened a new pull request, #22067: Update issue bot to javascript and add label management

damccorm opened a new pull request, #22067:
URL: https://github.com/apache/beam/pull/22067

   This does 2 things:
   
   1) Ports the existing label management issue to JS.
   2) Adds the ability to add or remove labels from an issue.
   
   Example of this in action - https://github.com/damccorm/playground/issues/19
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`).
    - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [x] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   [![Build python source distribution and wheels](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
damccorm commented on PR #22067:
URL: https://github.com/apache/beam/pull/22067#issuecomment-1167892622

   Ah, whoops - was missing files I'd had locally


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #22067:
URL: https://github.com/apache/beam/pull/22067#issuecomment-1167857134

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #22067:
URL: https://github.com/apache/beam/pull/22067#issuecomment-1167857146

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
damccorm commented on PR #22067:
URL: https://github.com/apache/beam/pull/22067#issuecomment-1167904672

   Ok, took a couple tries - looks like you can't specify a reason for the completed case to be accepted, but its working now - https://github.com/damccorm/playground/issues/15
   
   @Abacn please take another look


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
damccorm commented on PR #22067:
URL: https://github.com/apache/beam/pull/22067#issuecomment-1167857350

   R: @Abacn 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn commented on a diff in pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
Abacn commented on code in PR #22067:
URL: https://github.com/apache/beam/pull/22067#discussion_r907782885


##########
.github/workflows/self-assign.yml:
##########
@@ -23,29 +23,102 @@ jobs:
     if: ${{ !github.event.issue.pull_request }}
     runs-on: ubuntu-latest
     steps:
-    - run: |
-        BODY="$(jq '.comment.body' $GITHUB_EVENT_PATH)"
-        ISSUE_NUMBER="$(jq '.issue.number' $GITHUB_EVENT_PATH)"
-        LOGIN="$(jq '.comment.user.login' $GITHUB_EVENT_PATH | tr -d \")"
-        REPO="$(jq '.repository.full_name' $GITHUB_EVENT_PATH | tr -d \")"
-        ISSUE_JSON="$(jq '.issue' $GITHUB_EVENT_PATH)"
-        if [[ $BODY == *"$INPUT_TAKE"* && $BODY != *"\`$INPUT_TAKE\`"* ]]; then
-          echo "Assigning issue $ISSUE_NUMBER to $LOGIN"
-          echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees"
-          curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
-          curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/labels/awaiting%20triage
-        fi
-        if [[ $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"* ]]; then
-          ISSUE_CLOSE_CONFIG='"state":"closed"'
-          if [[ $BODY == *"not_planned"* ]]; then
-            ISSUE_CLOSE_CONFIG='"state":"closed","state_reason":"not_planned"'
-          fi
-          echo "Closing issue $ISSUE_NUMBER as {$ISSUE_CLOSE_CONFIG}"
-          echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER"
-          curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" -d "{$ISSUE_CLOSE_CONFIG}" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER
-        fi
-      shell: bash
-      env:
-        INPUT_TAKE: ".take-issue"
-        INPUT_CLOSE: ".close-issue"
-        GITHUB_TOKEN: ${{ github.token }}
\ No newline at end of file
+    - uses: actions/github-script@v6
+      with:
+        script: |
+          const body = context.payload.comment.body.split(' ');
+          for (let i = 0; i < body.length; i++) {
+            const bodyString = body[i].toLowerCase();
+            if (bodyString == '.take-issue') {
+              console.log(`Assigining issue to ${context.payload.comment.user.login}`);
+              github.rest.issues.addAssignees({
+                issue_number: context.issue.number,
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                assignees: [context.payload.comment.user.login]
+              });
+            } else if (bodyString == '.close-issue') {
+              console.log('Closing issue');
+              github.rest.issues.update({
+                issue_number: context.issue.number,
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                state: 'closed'
+              });

Review Comment:
   ```suggestion
                   state_reason: state_reason || undefined
                 });
   ```



##########
.github/workflows/self-assign.yml:
##########
@@ -23,29 +23,102 @@ jobs:
     if: ${{ !github.event.issue.pull_request }}
     runs-on: ubuntu-latest
     steps:
-    - run: |
-        BODY="$(jq '.comment.body' $GITHUB_EVENT_PATH)"
-        ISSUE_NUMBER="$(jq '.issue.number' $GITHUB_EVENT_PATH)"
-        LOGIN="$(jq '.comment.user.login' $GITHUB_EVENT_PATH | tr -d \")"
-        REPO="$(jq '.repository.full_name' $GITHUB_EVENT_PATH | tr -d \")"
-        ISSUE_JSON="$(jq '.issue' $GITHUB_EVENT_PATH)"
-        if [[ $BODY == *"$INPUT_TAKE"* && $BODY != *"\`$INPUT_TAKE\`"* ]]; then
-          echo "Assigning issue $ISSUE_NUMBER to $LOGIN"
-          echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees"
-          curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
-          curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/labels/awaiting%20triage
-        fi
-        if [[ $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"* ]]; then
-          ISSUE_CLOSE_CONFIG='"state":"closed"'
-          if [[ $BODY == *"not_planned"* ]]; then
-            ISSUE_CLOSE_CONFIG='"state":"closed","state_reason":"not_planned"'
-          fi
-          echo "Closing issue $ISSUE_NUMBER as {$ISSUE_CLOSE_CONFIG}"
-          echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER"
-          curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" -d "{$ISSUE_CLOSE_CONFIG}" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER
-        fi
-      shell: bash
-      env:
-        INPUT_TAKE: ".take-issue"
-        INPUT_CLOSE: ".close-issue"
-        GITHUB_TOKEN: ${{ github.token }}
\ No newline at end of file
+    - uses: actions/github-script@v6
+      with:
+        script: |
+          const body = context.payload.comment.body.split(' ');
+          for (let i = 0; i < body.length; i++) {
+            const bodyString = body[i].toLowerCase();
+            if (bodyString == '.take-issue') {
+              console.log(`Assigining issue to ${context.payload.comment.user.login}`);
+              github.rest.issues.addAssignees({
+                issue_number: context.issue.number,
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                assignees: [context.payload.comment.user.login]
+              });
+            } else if (bodyString == '.close-issue') {
+              console.log('Closing issue');

Review Comment:
   ```suggestion
                 if (i + 1 < body.length && body[i+1].toLowerCase() == 'not_planned') {
                   state_reason = 'not_planned';
                 }
                 console.log('Closing issue');
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn commented on a diff in pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
Abacn commented on code in PR #22067:
URL: https://github.com/apache/beam/pull/22067#discussion_r908507214


##########
.github/workflows/self-assign.yml:
##########
@@ -23,29 +23,118 @@ jobs:
     if: ${{ !github.event.issue.pull_request }}
     runs-on: ubuntu-latest
     steps:
-    - run: |
-        BODY="$(jq '.comment.body' $GITHUB_EVENT_PATH)"
-        ISSUE_NUMBER="$(jq '.issue.number' $GITHUB_EVENT_PATH)"
-        LOGIN="$(jq '.comment.user.login' $GITHUB_EVENT_PATH | tr -d \")"
-        REPO="$(jq '.repository.full_name' $GITHUB_EVENT_PATH | tr -d \")"
-        ISSUE_JSON="$(jq '.issue' $GITHUB_EVENT_PATH)"
-        if [[ $BODY == *"$INPUT_TAKE"* && $BODY != *"\`$INPUT_TAKE\`"* ]]; then
-          echo "Assigning issue $ISSUE_NUMBER to $LOGIN"
-          echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees"
-          curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
-          curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/labels/awaiting%20triage
-        fi
-        if [[ $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"* ]]; then
-          ISSUE_CLOSE_CONFIG='"state":"closed"'
-          if [[ $BODY == *"not_planned"* ]]; then
-            ISSUE_CLOSE_CONFIG='"state":"closed","state_reason":"not_planned"'
-          fi
-          echo "Closing issue $ISSUE_NUMBER as {$ISSUE_CLOSE_CONFIG}"
-          echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER"
-          curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" -d "{$ISSUE_CLOSE_CONFIG}" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER
-        fi
-      shell: bash
-      env:
-        INPUT_TAKE: ".take-issue"
-        INPUT_CLOSE: ".close-issue"
-        GITHUB_TOKEN: ${{ github.token }}
\ No newline at end of file
+    - uses: actions/github-script@v6
+      with:
+        script: |
+          const body = context.payload.comment.body.split(' ');
+          for (let i = 0; i < body.length; i++) {
+            const bodyString = body[i].toLowerCase();
+            if (bodyString == '.take-issue') {
+              console.log(`Assigining issue to ${context.payload.comment.user.login}`);
+              github.rest.issues.addAssignees({
+                issue_number: context.issue.number,
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                assignees: [context.payload.comment.user.login]
+              });
+              github.rest.issues.removeLabel({
+                issue_number: context.issue.number,
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                name: 'awaiting triage'
+              });
+            } else if (bodyString == '.close-issue') {
+              console.log('Closing issue');
+              if (i + 1 < body.length && body[i+1].toLowerCase() == 'not_planned') {
+                github.rest.issues.update({
+                  issue_number: context.issue.number,
+                  owner: context.repo.owner,
+                  repo: context.repo.repo,
+                  state: 'closed',
+                  state_reason: 'not_planned'
+                });
+              }
+              
+              github.rest.issues.update({

Review Comment:
   if closed as not_planned, then both the above and the below request will be send. Though currently it works fine, it may still nice to cover the second request in an else clause.
   
   Other than that lgtm. Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on a diff in pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
damccorm commented on code in PR #22067:
URL: https://github.com/apache/beam/pull/22067#discussion_r907789281


##########
.github/workflows/self-assign.yml:
##########
@@ -23,29 +23,102 @@ jobs:
     if: ${{ !github.event.issue.pull_request }}
     runs-on: ubuntu-latest
     steps:
-    - run: |
-        BODY="$(jq '.comment.body' $GITHUB_EVENT_PATH)"
-        ISSUE_NUMBER="$(jq '.issue.number' $GITHUB_EVENT_PATH)"
-        LOGIN="$(jq '.comment.user.login' $GITHUB_EVENT_PATH | tr -d \")"
-        REPO="$(jq '.repository.full_name' $GITHUB_EVENT_PATH | tr -d \")"
-        ISSUE_JSON="$(jq '.issue' $GITHUB_EVENT_PATH)"
-        if [[ $BODY == *"$INPUT_TAKE"* && $BODY != *"\`$INPUT_TAKE\`"* ]]; then
-          echo "Assigning issue $ISSUE_NUMBER to $LOGIN"
-          echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees"
-          curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
-          curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/labels/awaiting%20triage
-        fi
-        if [[ $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"* ]]; then
-          ISSUE_CLOSE_CONFIG='"state":"closed"'
-          if [[ $BODY == *"not_planned"* ]]; then
-            ISSUE_CLOSE_CONFIG='"state":"closed","state_reason":"not_planned"'
-          fi
-          echo "Closing issue $ISSUE_NUMBER as {$ISSUE_CLOSE_CONFIG}"
-          echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER"
-          curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" -d "{$ISSUE_CLOSE_CONFIG}" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER
-        fi
-      shell: bash
-      env:
-        INPUT_TAKE: ".take-issue"
-        INPUT_CLOSE: ".close-issue"
-        GITHUB_TOKEN: ${{ github.token }}
\ No newline at end of file
+    - uses: actions/github-script@v6
+      with:
+        script: |
+          const body = context.payload.comment.body.split(' ');
+          for (let i = 0; i < body.length; i++) {
+            const bodyString = body[i].toLowerCase();
+            if (bodyString == '.take-issue') {
+              console.log(`Assigining issue to ${context.payload.comment.user.login}`);
+              github.rest.issues.addAssignees({
+                issue_number: context.issue.number,
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                assignees: [context.payload.comment.user.login]
+              });
+            } else if (bodyString == '.close-issue') {
+              console.log('Closing issue');

Review Comment:
   Oh wow - this does work. I was expecting there to be some validation on the octokit end preventing this since its not documented, but it doesn't look like there is



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #22067:
URL: https://github.com/apache/beam/pull/22067#issuecomment-1167857141

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn commented on a diff in pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
Abacn commented on code in PR #22067:
URL: https://github.com/apache/beam/pull/22067#discussion_r908507214


##########
.github/workflows/self-assign.yml:
##########
@@ -23,29 +23,118 @@ jobs:
     if: ${{ !github.event.issue.pull_request }}
     runs-on: ubuntu-latest
     steps:
-    - run: |
-        BODY="$(jq '.comment.body' $GITHUB_EVENT_PATH)"
-        ISSUE_NUMBER="$(jq '.issue.number' $GITHUB_EVENT_PATH)"
-        LOGIN="$(jq '.comment.user.login' $GITHUB_EVENT_PATH | tr -d \")"
-        REPO="$(jq '.repository.full_name' $GITHUB_EVENT_PATH | tr -d \")"
-        ISSUE_JSON="$(jq '.issue' $GITHUB_EVENT_PATH)"
-        if [[ $BODY == *"$INPUT_TAKE"* && $BODY != *"\`$INPUT_TAKE\`"* ]]; then
-          echo "Assigning issue $ISSUE_NUMBER to $LOGIN"
-          echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees"
-          curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
-          curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/labels/awaiting%20triage
-        fi
-        if [[ $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"* ]]; then
-          ISSUE_CLOSE_CONFIG='"state":"closed"'
-          if [[ $BODY == *"not_planned"* ]]; then
-            ISSUE_CLOSE_CONFIG='"state":"closed","state_reason":"not_planned"'
-          fi
-          echo "Closing issue $ISSUE_NUMBER as {$ISSUE_CLOSE_CONFIG}"
-          echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER"
-          curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" -d "{$ISSUE_CLOSE_CONFIG}" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER
-        fi
-      shell: bash
-      env:
-        INPUT_TAKE: ".take-issue"
-        INPUT_CLOSE: ".close-issue"
-        GITHUB_TOKEN: ${{ github.token }}
\ No newline at end of file
+    - uses: actions/github-script@v6
+      with:
+        script: |
+          const body = context.payload.comment.body.split(' ');
+          for (let i = 0; i < body.length; i++) {
+            const bodyString = body[i].toLowerCase();
+            if (bodyString == '.take-issue') {
+              console.log(`Assigining issue to ${context.payload.comment.user.login}`);
+              github.rest.issues.addAssignees({
+                issue_number: context.issue.number,
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                assignees: [context.payload.comment.user.login]
+              });
+              github.rest.issues.removeLabel({
+                issue_number: context.issue.number,
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                name: 'awaiting triage'
+              });
+            } else if (bodyString == '.close-issue') {
+              console.log('Closing issue');
+              if (i + 1 < body.length && body[i+1].toLowerCase() == 'not_planned') {
+                github.rest.issues.update({
+                  issue_number: context.issue.number,
+                  owner: context.repo.owner,
+                  repo: context.repo.repo,
+                  state: 'closed',
+                  state_reason: 'not_planned'
+                });
+              }
+              
+              github.rest.issues.update({

Review Comment:
   if closed as planned, then both the above and the below request will be send. Though currently it works fine, it may still nice to cover the second request in an else clause.
   
   Other than that lgtm. Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #22067:
URL: https://github.com/apache/beam/pull/22067#issuecomment-1167857133

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on a diff in pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
damccorm commented on code in PR #22067:
URL: https://github.com/apache/beam/pull/22067#discussion_r908588581


##########
.github/workflows/self-assign.yml:
##########
@@ -23,29 +23,118 @@ jobs:
     if: ${{ !github.event.issue.pull_request }}
     runs-on: ubuntu-latest
     steps:
-    - run: |
-        BODY="$(jq '.comment.body' $GITHUB_EVENT_PATH)"
-        ISSUE_NUMBER="$(jq '.issue.number' $GITHUB_EVENT_PATH)"
-        LOGIN="$(jq '.comment.user.login' $GITHUB_EVENT_PATH | tr -d \")"
-        REPO="$(jq '.repository.full_name' $GITHUB_EVENT_PATH | tr -d \")"
-        ISSUE_JSON="$(jq '.issue' $GITHUB_EVENT_PATH)"
-        if [[ $BODY == *"$INPUT_TAKE"* && $BODY != *"\`$INPUT_TAKE\`"* ]]; then
-          echo "Assigning issue $ISSUE_NUMBER to $LOGIN"
-          echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees"
-          curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
-          curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/labels/awaiting%20triage
-        fi
-        if [[ $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"* ]]; then
-          ISSUE_CLOSE_CONFIG='"state":"closed"'
-          if [[ $BODY == *"not_planned"* ]]; then
-            ISSUE_CLOSE_CONFIG='"state":"closed","state_reason":"not_planned"'
-          fi
-          echo "Closing issue $ISSUE_NUMBER as {$ISSUE_CLOSE_CONFIG}"
-          echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER"
-          curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" -d "{$ISSUE_CLOSE_CONFIG}" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER
-        fi
-      shell: bash
-      env:
-        INPUT_TAKE: ".take-issue"
-        INPUT_CLOSE: ".close-issue"
-        GITHUB_TOKEN: ${{ github.token }}
\ No newline at end of file
+    - uses: actions/github-script@v6
+      with:
+        script: |
+          const body = context.payload.comment.body.split(' ');
+          for (let i = 0; i < body.length; i++) {
+            const bodyString = body[i].toLowerCase();
+            if (bodyString == '.take-issue') {
+              console.log(`Assigining issue to ${context.payload.comment.user.login}`);
+              github.rest.issues.addAssignees({
+                issue_number: context.issue.number,
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                assignees: [context.payload.comment.user.login]
+              });
+              github.rest.issues.removeLabel({
+                issue_number: context.issue.number,
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                name: 'awaiting triage'
+              });
+            } else if (bodyString == '.close-issue') {
+              console.log('Closing issue');
+              if (i + 1 < body.length && body[i+1].toLowerCase() == 'not_planned') {
+                github.rest.issues.update({
+                  issue_number: context.issue.number,
+                  owner: context.repo.owner,
+                  repo: context.repo.repo,
+                  state: 'closed',
+                  state_reason: 'not_planned'
+                });
+              }
+              
+              github.rest.issues.update({

Review Comment:
   Good catch - updated!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm merged pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
damccorm merged PR #22067:
URL: https://github.com/apache/beam/pull/22067


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #22067: Update issue bot to javascript and add label management

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #22067:
URL: https://github.com/apache/beam/pull/22067#issuecomment-1167857143

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org