comvent icon indicating copy to clipboard operation
comvent copied to clipboard

Comvent ⚑️ Playground 🏞

Open rytswd opened this issue 4 years ago β€’ 60 comments

😎 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

rytswd avatar Jan 08 '21 13:01 rytswd

/hello-world /random

rytswd avatar Jan 08 '21 13:01 rytswd

Command /hello-world was triggered by the comment

github-actions[bot] avatar Jan 08 '21 13:01 github-actions[bot]

Command /random was triggered by the comment

github-actions[bot] avatar Jan 08 '21 13:01 github-actions[bot]

Found abusive comment! 😰 The comment was thus removed.

github-actions[bot] avatar Jan 08 '21 13:01 github-actions[bot]

/random

lgmorand avatar Feb 21 '21 20:02 lgmorand

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

rytswd avatar Feb 21 '21 22:02 rytswd

Command /random was triggered by the comment

github-actions[bot] avatar Feb 21 '21 22:02 github-actions[bot]

Command /hello-world was triggered by the comment

github-actions[bot] avatar Feb 21 '21 22:02 github-actions[bot]

Command /random was triggered by the comment

github-actions[bot] avatar Feb 21 '21 22:02 github-actions[bot]

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!

rytswd avatar Feb 24 '21 12:02 rytswd

maybe TLDR; :D I just copy-pasted your precedent comment

lgmorand avatar Feb 24 '21 13:02 lgmorand

/hello-world

lgmorand avatar Feb 24 '21 13:02 lgmorand

Command /hello-world was triggered by the comment

github-actions[bot] avatar Feb 24 '21 13:02 github-actions[bot]

Thanks! It's a good point, I added a TL;DR section πŸ˜†

rytswd avatar Feb 24 '21 15:02 rytswd

/echo this is a test message

rytswd avatar Apr 19 '21 09:04 rytswd

Command /echo was triggered by the comment. You echoed "found".

github-actions[bot] avatar Apr 19 '21 09:04 github-actions[bot]

/echo this is a test message

rytswd avatar Apr 19 '21 09:04 rytswd

Command /echo was triggered by the comment. You echoed "this is a test message".

github-actions[bot] avatar Apr 19 '21 09:04 github-actions[bot]

/echo this is test, it may fail due to the job condition.

rytswd avatar Apr 21 '21 14:04 rytswd

/echo this is another test.

There was an error with the job condition.

rytswd avatar Apr 21 '21 14:04 rytswd

Command /echo was triggered by the comment. You echoed "".

github-actions[bot] avatar Apr 21 '21 14:04 github-actions[bot]

/echo this is another test, this time the response will look up the string correctly.

rytswd avatar Apr 21 '21 14:04 rytswd

Command /echo was triggered by the comment. You echoed "this is another test, this time the response will look up the string correctly.".

github-actions[bot] avatar Apr 21 '21 14:04 github-actions[bot]

/random

iam-py-test avatar Jun 01 '21 22:06 iam-py-test

/echo test

iam-py-test avatar Jun 01 '21 22:06 iam-py-test

Command /echo was triggered by the comment. You echoed "test".

github-actions[bot] avatar Jun 01 '21 22:06 github-actions[bot]

/hello-world

iam-py-test avatar Jun 01 '21 22:06 iam-py-test

Command /hello-world was triggered by the comment

github-actions[bot] avatar Jun 01 '21 22:06 github-actions[bot]

Found abusive comment! 😰 The comment was thus removed.

github-actions[bot] avatar Jun 01 '21 22:06 github-actions[bot]

Found abusive comment! 😰 The comment was thus removed.

github-actions[bot] avatar Jun 01 '21 22:06 github-actions[bot]

@rytswd is there a way to mention the name of the person from the original comment?

iam-py-test avatar Jun 01 '21 22:06 iam-py-test

@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 ☺️

rytswd avatar Jun 01 '21 22:06 rytswd

@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

iam-py-test avatar Jun 01 '21 23:06 iam-py-test

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 avatar Jun 06 '21 19:06 iam-py-test

@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 πŸ‘

rytswd avatar Jun 08 '21 15:06 rytswd

@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!

iam-py-test avatar Jun 08 '21 16:06 iam-py-test

@rytswd When I tried it, I got this error: image Repo: https://github.com/iam-py-test/my_filters_001 Sorry I did not respond earlier; I was busy.

iam-py-test avatar Jun 08 '21 17:06 iam-py-test

/weather

iam-py-test avatar Jun 08 '21 17:06 iam-py-test

Command /weather was triggered by the comment

github-actions[bot] avatar Jun 08 '21 17:06 github-actions[bot]

Command /weather was triggered by the comment

test

iam-py-test avatar Jun 08 '21 17:06 iam-py-test

/weather

iam-py-test avatar Jun 08 '21 17:06 iam-py-test

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

rytswd avatar Jun 08 '21 18:06 rytswd

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

iam-py-test avatar Jun 08 '21 18:06 iam-py-test

I tried that and I get this error: image

I copy-pasted everything from this repo.

Please forgive me for my errors as I am new to GitHub actions Thanks for your help

iam-py-test avatar Jun 08 '21 18:06 iam-py-test

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.
      #

rytswd avatar Jun 08 '21 19:06 rytswd

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!

iam-py-test avatar Jun 08 '21 19:06 iam-py-test

I tried it & it worked! Thanks @rytswd

iam-py-test avatar Jun 08 '21 19:06 iam-py-test

/echo run this test

abhimanyuseth-alation avatar Aug 21 '21 06:08 abhimanyuseth-alation

Command /echo was triggered by the comment. You echoed "run this test".

github-actions[bot] avatar Aug 21 '21 06:08 github-actions[bot]

/hello-world

RupertBarrow avatar Dec 03 '21 22:12 RupertBarrow

Command /hello-world was triggered by the comment

github-actions[bot] avatar Dec 03 '21 22:12 github-actions[bot]

/echo bold test

iam-py-test avatar Dec 03 '21 22:12 iam-py-test

Command /echo was triggered by the comment. You echoed "bold test".

github-actions[bot] avatar Dec 03 '21 22:12 github-actions[bot]

/echo **bold** <-- can’t see me--> #1

iam-py-test avatar Dec 03 '21 22:12 iam-py-test

/echo it works?

scratchmex avatar Apr 21 '22 02:04 scratchmex

Command /echo was triggered by the comment. You echoed "it works?".

github-actions[bot] avatar Apr 21 '22 02:04 github-actions[bot]