You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "mistercrunch (via GitHub)" <gi...@apache.org> on 2024/02/08 05:07:58 UTC
[PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
mistercrunch opened a new pull request, #27046:
URL: https://github.com/apache/superset/pull/27046
### SUMMARY
A while back we had a Superset bot that live in some hosted app that
would listen for events and do things.
Now that GH actions have evolved, it's pretty trivial to do this directly
of GH infra, and this is a proof of concept, re-implementing one of the
features of the bot, allowing for non-committers to add/remove labels from
PRs and issues.
Here you can simply add comment `@supersetbot label "some_label"` and it'll
do it's thing. Similarly you can `@supersetbot unlabel "some_label"` to
remove a label.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #27046:
URL: https://github.com/apache/superset/pull/27046#issuecomment-1936300377
@supersetbot label preset-io
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #27046:
URL: https://github.com/apache/superset/pull/27046#issuecomment-1933409142
@supersetbot label preset-io
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "betodealmeida (via GitHub)" <gi...@apache.org>.
betodealmeida commented on code in PR #27046:
URL: https://github.com/apache/superset/pull/27046#discussion_r1484609884
##########
.github/workflows/supersetbot.yml:
##########
@@ -0,0 +1,66 @@
+name: SupersetBot Workflow
+
+on:
+ issue_comment:
+ types: [created, edited]
+
+ # Making the workflow testable since `issue_comment` only trigges on
+ # the default branch
+ workflow_dispatch:
+ inputs:
+ comment_body:
+ description: 'Comment Body'
+ required: true
+ type: string
+ issue_number:
+ required: true
+ type: string
+
+
+jobs:
+ supersetbot:
+ runs-on: ubuntu-latest
+ if: >
+ github.event_name == 'workflow_dispatch' ||
+ (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@supersetbot'))
+ steps:
+ - name: Execute SupersetBot Command
+ uses: actions/github-script@v7
+ with:
+ script: |
+ const commentBody = context.eventName === 'workflow_dispatch' ?
+ context.payload.inputs.comment_body :
+ context.payload.comment.body;
+ const issueNumber = context.eventName === 'workflow_dispatch' ?
+ context.payload.inputs.issue_number :
+ context.issue.number;
+ const commandPrefix = '@supersetbot';
+
+ const regex = /"([^"]+)"|\S+/g;
+ let matches = [...commentBody.slice(commandPrefix.length).trim().matchAll(regex)];
+ // Extracting the command which is the first match
+ const command = matches[0] ? matches[0][0] : null;
+ // Generating args array, skipping the first element (command)
+ const args = matches.slice(1).map(match => match[1] ? match[1] : match[0]);
+
+ if (command === 'label') {
+ const label = args[0];
+ await github.rest.issues.addLabels({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: issueNumber,
+ labels: [label],
+ }).catch(error => {
+ console.log(error);
+ });
Review Comment:
```suggestion
}).catch(console.log);
```
##########
.github/workflows/supersetbot.yml:
##########
@@ -0,0 +1,66 @@
+name: SupersetBot Workflow
+
+on:
+ issue_comment:
+ types: [created, edited]
+
+ # Making the workflow testable since `issue_comment` only trigges on
Review Comment:
```suggestion
# Making the workflow testable since `issue_comment` only triggers on
```
##########
.github/workflows/supersetbot.yml:
##########
@@ -0,0 +1,66 @@
+name: SupersetBot Workflow
+
+on:
+ issue_comment:
+ types: [created, edited]
+
+ # Making the workflow testable since `issue_comment` only trigges on
+ # the default branch
+ workflow_dispatch:
+ inputs:
+ comment_body:
+ description: 'Comment Body'
+ required: true
+ type: string
+ issue_number:
+ required: true
+ type: string
+
+
+jobs:
+ supersetbot:
+ runs-on: ubuntu-latest
+ if: >
+ github.event_name == 'workflow_dispatch' ||
+ (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@supersetbot'))
+ steps:
+ - name: Execute SupersetBot Command
+ uses: actions/github-script@v7
+ with:
+ script: |
+ const commentBody = context.eventName === 'workflow_dispatch' ?
+ context.payload.inputs.comment_body :
+ context.payload.comment.body;
+ const issueNumber = context.eventName === 'workflow_dispatch' ?
+ context.payload.inputs.issue_number :
+ context.issue.number;
+ const commandPrefix = '@supersetbot';
+
+ const regex = /"([^"]+)"|\S+/g;
+ let matches = [...commentBody.slice(commandPrefix.length).trim().matchAll(regex)];
+ // Extracting the command which is the first match
+ const command = matches[0] ? matches[0][0] : null;
+ // Generating args array, skipping the first element (command)
+ const args = matches.slice(1).map(match => match[1] ? match[1] : match[0]);
+
+ if (command === 'label') {
+ const label = args[0];
+ await github.rest.issues.addLabels({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: issueNumber,
+ labels: [label],
+ }).catch(error => {
+ console.log(error);
+ });
+ } else if (command === 'unlabel') {
+ const label = args[0];
+ await github.rest.issues.removeLabel({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: issueNumber,
+ name: label,
+ }).catch(error => {
+ console.log(error);
+ });
Review Comment:
```suggestion
}).catch(console.log);
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #27046:
URL: https://github.com/apache/superset/pull/27046#issuecomment-1933422596
@supersetbot label preset-io
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #27046:
URL: https://github.com/apache/superset/pull/27046#issuecomment-1933425358
@supersetbot label preset-io
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): introduce `supersetbot` as its own npm package, CLI and comment-operated bot [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch merged PR #27046:
URL: https://github.com/apache/superset/pull/27046
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #27046:
URL: https://github.com/apache/superset/pull/27046#issuecomment-1933413296
@supersetbot label preset-io
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #27046:
URL: https://github.com/apache/superset/pull/27046#issuecomment-1933425889
test
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on PR #27046:
URL: https://github.com/apache/superset/pull/27046#issuecomment-1936229782
@supersetbot label preset-io
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #27046:
URL: https://github.com/apache/superset/pull/27046#issuecomment-1933391394
@supersetbot label preset-io
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #27046:
URL: https://github.com/apache/superset/pull/27046#issuecomment-1933440274
Oh wow, i was really confused, this only triggers if it's on `master`:
<img width="774" alt="Screenshot 2024-02-07 at 10 28 31 PM" src="https://github.com/apache/superset/assets/487433/13373c1f-4b2e-4b25-9557-59c42c4adc8a">
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #27046:
URL: https://github.com/apache/superset/pull/27046#issuecomment-1933372474
@supersetbot label preset-io
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #27046:
URL: https://github.com/apache/superset/pull/27046#issuecomment-1933394423
@supersetbot label preset-io
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on PR #27046:
URL: https://github.com/apache/superset/pull/27046#issuecomment-1936228706
@supersetbot label "preset-io"
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(supersetbot): re-implement labeling bot as a GitHub action [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #27046:
URL: https://github.com/apache/superset/pull/27046#issuecomment-1933413813
@supersetbot label preset-io
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org