comvent
comvent copied to clipboard
Comvent β‘οΈ Playground π
π TL; DR
Comment to this issue with the following one line (no need to wrap in backticks):
/hello-world
You will see an automated comment response in 1 min or so!
π About
This is only a playground π You can comment on this to see Comvent in action, which uses https://github.com/actions/github-script.
Multiple commands can be issued at once in a single comment, as long as they are provided in separate lines.
π Note
Because GitHub Action takes several seconds to initiate the action, you may see up to 1 min delay.
π» Available Commands
For all users
-
/weather
: automation responds with a comment -
/hello-world
: automation responds with a comment -
/echo (.+)$
: automation responds with your comment in(.+)
portion of regexp
Ref: https://github.com/rytswd/comvent/blob/main/.github/workflows/issue-comment-blacklist-demo.yaml
For specific users (currently set for only @rytswd)
-
/random
: automation responds with a comment -
/today
: automation responds with a comment -
/httpbin
: automation responds with a comment
Ref: https://github.com/rytswd/comvent/blob/main/.github/workflows/issue-comment-whitelist-demo.yaml
Abuse Monitor
-
some abusive content
: If you write a comment including this exact phrase in a single line, you will see the comment being removed via the automation. You will also see a comment about the comment deletion.
Ref: https://github.com/rytswd/comvent/blob/main/.github/workflows/abusive-comment-demo.yaml
/hello-world /random
Command /hello-world
was triggered by the comment
Command /random
was triggered by the comment
Found abusive comment! π° The comment was thus removed.
/random
Thanks for checking out, and it does look like something is not functioning correctly when comment is edited, perhaps... π₯ I'll check more into this in the coming days, and will get back to the thread.
For now, this is another test.
/random
After edit:
/hello-world
/random
Command /random
was triggered by the comment
Command /hello-world
was triggered by the comment
Command /random
was triggered by the comment
Hi @lgmorand - I think your earlier attempt didn't match the comvent setup, because you were triggering the command for "specific" user setup, which is triggered only for whitelisted user list (in this case it only has myself @rytswd listed).
If you instead trigger with comment such as /weather
or /hello-world
, it should work and you get some automation in action!
maybe TLDR; :D I just copy-pasted your precedent comment
/hello-world
Command /hello-world
was triggered by the comment
Thanks! It's a good point, I added a TL;DR section π
/echo this is a test message
Command /echo
was triggered by the comment. You echoed "found".
/echo this is a test message
Command /echo
was triggered by the comment. You echoed "this is a test message".
/echo this is test, it may fail due to the job condition.
/echo this is another test.
There was an error with the job condition.
Command /echo
was triggered by the comment. You echoed "".
/echo this is another test, this time the response will look up the string correctly.
Command /echo
was triggered by the comment. You echoed "this is another test, this time the response will look up the string correctly.".
/random
/echo test
Command /echo
was triggered by the comment. You echoed "test".
/hello-world
Command /hello-world
was triggered by the comment
Found abusive comment! π° The comment was thus removed.
Found abusive comment! π° The comment was thus removed.
@rytswd is there a way to mention the name of the person from the original comment?
@iam-py-test
Do you mean to put the username along with the comment from github-actions
above?
If so, you can write the original comment sender by ${{ github.event.sender.login }}
as a part of GitHub Action step. This is something that GitHub provides, which you can find more in https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issue_comment π
Comvent itself does not keep hold of the username in its output. If there is a use case for that, it would be great if you can provide more details and background in a separate issue, so that it can be considered for future enhancements βΊοΈ
@iam-py-test Do you mean to put the username along with the comment from
github-actions
above? If so, you can write the original comment sender by${{ github.event.sender.login }}
as a part of GitHub Action step. This is something that GitHub provides, which you can find more in https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issue_comment πComvent itself does not keep hold of the username in its output. If there is a use case for that, it would be great if you can provide more details and background in a separate issue, so that it can be considered for future enhancements βΊοΈ
Ok, thanks
Please forgive me for not knowing, but does anyone know how to install this? I tried the instructions & it did not work. Thanks!
@iam-py-test Sorry for the delayed response, what sort of error did you get from the instruction? (and which instruction did you follow?)
The installation should be straightforward GitHub Action usage, something like:
jobs:
chatbot:
name: ChatBot
runs-on: ubuntu-latest
steps:
- name: Handle with Comvent
uses: rytswd/[email protected] # Latest available as of now
id: comvent
with:
token: ${{ secrets.GITHUB_TOKEN }}
config-path: .github/comvent-chatbot.yaml # Assumes this file exists
If you could provide a bit more detail, I should be able to assist you further π
@iam-py-test Sorry for the delayed response, what sort of error did you get from the instruction? (and which instruction did you follow?)
The installation should be straightforward GitHub Action usage, something like:
jobs: chatbot: name: ChatBot runs-on: ubuntu-latest steps: - name: Handle with Comvent uses: rytswd/[email protected] # Latest available as of now id: comvent with: token: ${{ secrets.GITHUB_TOKEN }} config-path: .github/comvent-chatbot.yaml # Assumes this file exists
If you could provide a bit more detail, I should be able to assist you further π
Ok! @rytswd Thanks! I think I just misunderstood something!
@rytswd When I tried it, I got this error:
Repo: https://github.com/iam-py-test/my_filters_001
Sorry I did not respond earlier; I was busy.
/weather
Command /weather
was triggered by the comment
Command
/weather
was triggered by the comment
test
/weather
If you are referring to getting an error with https://github.com/iam-py-test/my_filters_001/blob/main/.github/workflows/comment.yml, it doesn't look to conform to GitHub Actions requirements (i.e. missing on
stanza, etc.). I'd suggest checking out GitHub Actions documentation for the actual spec.
If you want to simply get the same result as this repo's example, I suggest you check out the setup here https://github.com/rytswd/comvent/blob/main/.github/workflows/issue-comment-blacklist-demo.yaml
If you are referring to getting an error with https://github.com/iam-py-test/my_filters_001/blob/main/.github/workflows/comment.yml, it doesn't look to conform to GitHub Actions requirements (i.e. missing
on
stanza, etc.). I'd suggest checking out GitHub Actions documentation for the actual spec.If you want to simply get the same result as this repo's example, I suggest you check out the setup here https://github.com/rytswd/comvent/blob/main/.github/workflows/issue-comment-blacklist-demo.yaml
Ok! Will do. Thank you for your help
I tried that and I get this error:
I copy-pasted everything from this repo.
Please forgive me for my errors as I am new to GitHub actions Thanks for your help
Apologies, I should have been clearer - you cannot copy directly from the aforementioned file, as this repo does not pull in the GitHub Action spec but builds itself in the action setup. You need to combine the file content with the setup mentioned here: https://github.com/rytswd/comvent/issues/24#issuecomment-856888939
You can see a complete example here https://github.com/rytswd/comvent#chatbot-setup, by clicking on Click to view full example
. (Note that this refers to v0.3)
name: ChatBot
on:
issue_comment:
# This shouldn't be called for comment deletion
types:
- created
- edited
jobs:
chatbot:
name: With latest code base
runs-on: ubuntu-latest
steps:
- name: Handle with Comvent
uses: rytswd/[email protected]
id: comvent
with:
token: ${{ secrets.GITHUB_TOKEN }}
config-path: .github/comvent-chatbot.yaml
# The below only runs when Comvent finds matching comment.
# This assumes that Comvent config holding 'command-random' as a keyword.
- if: steps.comvent.outputs.command-random != ''
name: Handle random event
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# An example of responding to a comment.
script: |
const comment = `Command \`/random\` was triggered by the comment`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
})
#
# You can repeat similar handling based on the Comvent config.
#
Apologies, I should have been clearer - you cannot copy directly from the aforementioned file, as this repo does not pull in the GitHub Action spec but builds itself in the action setup. You need to combine the file content with the setup mentioned here: #24 (comment)
You can see a complete example here https://github.com/rytswd/comvent#chatbot-setup, by clicking on
Click to view full example
. (Note that this refers to v0.3)name: ChatBot on: issue_comment: # This shouldn't be called for comment deletion types: - created - edited jobs: chatbot: name: With latest code base runs-on: ubuntu-latest steps: - name: Handle with Comvent uses: rytswd/[email protected] id: comvent with: token: ${{ secrets.GITHUB_TOKEN }} config-path: .github/comvent-chatbot.yaml # The below only runs when Comvent finds matching comment. # This assumes that Comvent config holding 'command-random' as a keyword. - if: steps.comvent.outputs.command-random != '' name: Handle random event uses: actions/github-script@v3 with: github-token: ${{ secrets.GITHUB_TOKEN }} # An example of responding to a comment. script: | const comment = `Command \`/random\` was triggered by the comment`; github.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: comment }) # # You can repeat similar handling based on the Comvent config. #
@rytswd Thank you!
I tried it & it worked! Thanks @rytswd
/echo run this test
Command /echo
was triggered by the comment. You echoed "run this test".
/hello-world
Command /hello-world
was triggered by the comment
/echo bold test
Command /echo
was triggered by the comment. You echoed "bold test".
/echo **bold** <-- canβt see me--> #1
/echo it works?
Command /echo
was triggered by the comment. You echoed "it works?".