{"id":20359975,"url":"https://github.com/rytswd/comvent","last_synced_at":"2025-04-12T03:33:22.786Z","repository":{"id":37797784,"uuid":"206326836","full_name":"rytswd/comvent","owner":"rytswd","description":"⚡️ Comvent - Simple control for GitHub Actions workflow with \"comment event\", allowing you to parse comments with regular expression","archived":false,"fork":false,"pushed_at":"2024-02-05T16:15:11.000Z","size":22511,"stargazers_count":11,"open_issues_count":9,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-14T13:31:01.082Z","etag":null,"topics":["github-actions","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rytswd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-04T13:32:45.000Z","updated_at":"2024-06-27T09:28:31.000Z","dependencies_parsed_at":"2023-01-11T17:21:21.984Z","dependency_job_id":"7377226a-5ff8-498d-88b5-a3511ce1634f","html_url":"https://github.com/rytswd/comvent","commit_stats":{"total_commits":567,"total_committers":2,"mean_commits":283.5,"dds":"0.20811287477954143","last_synced_commit":"74a8380664b48f7da28b75391bdc241883af4d91"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":"actions/typescript-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rytswd%2Fcomvent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rytswd%2Fcomvent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rytswd%2Fcomvent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rytswd%2Fcomvent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rytswd","download_url":"https://codeload.github.com/rytswd/comvent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248513113,"owners_count":21116760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-actions","typescript"],"created_at":"2024-11-14T23:37:00.259Z","updated_at":"2025-04-12T03:33:22.755Z","avatar_url":"https://github.com/rytswd.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚡️ Comvent\n\n\u003e Simple control for GitHub Actions to handle \"comment event\" - a building block for rich comment handling\n\n[![Build Status](https://github.com/rytswd/comvent/workflows/build-test/badge.svg)](build-status) | [![License: MIT](https://img.shields.io/badge/License-MIT-powderblue.svg)](mit) | [![GitHub Release Date](https://img.shields.io/github/release-date/rytswd/comvent?color=powderblue)](releases)\n\n![Example in action](./doc/asset/example01.png)\n\n\u003c!--Placeholder--\u003e\n\n[build-status]: https://github.com/rytswd/comvent/actions\n[mit]: https://opensource.org/licenses/MIT\n[releases]: https://github.com/rytswd/comvent/releases\n\n## 🌅 Contents\n\n- [Examples](#-examples)\n- [Action Inputs](#-action-inputs)\n- [Comvent Configuration File](#%EF%B8%8F-comvent-configuration-file)\n- [Action Outputs](#-action-outputs)\n\n## 🚀 Examples\n\nComvent is being used in this repo as well. You can check out [this issue](https://github.com/rytswd/comvent/issues/24) and comment to see the actual Comvent offerings in action! 🏃\n\n### ChatBot Setup\n\nIt is pretty easy to provide simplistic ChatBot experience with PR / Issue comment.\n\nYou can add Comvent setup at the beginning of the `issue_comment` event, and use its output to run any step afterwards based on the patterns found. The below is an example to simply repsond to a comment.\n\n\u003e `.github/workflows/chatbot.yaml`\n\n```yaml\n- name: Handle with Comvent\n  uses: rytswd/comvent@v0.3\n  id: comvent\n  with:\n    token: ${{ secrets.GITHUB_TOKEN }}\n    config-path: .github/comvent-chatbot.yaml\n\n# The below only runs when Comvent finds matching comment.\n# This assumes that Comvent config holding 'command-random' as a keyword.\n- if: steps.comvent.outputs.command-random != ''\n  name: Handle random event\n  uses: actions/github-script@v3\n  with:\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n    # An example of responding to a comment.\n    script: |\n      const comment = `Command \\`/random\\` was triggered by the comment`;\n\n      github.issues.createComment({\n        issue_number: context.issue.number,\n        owner: context.repo.owner,\n        repo: context.repo.repo,\n        body: comment\n      })\n\n#\n# You can repeat similar handling based on the Comvent config.\n#\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to view full example\u003c/summary\u003e\n\n\u003e `.github/workflows/chatbot.yaml`\n\n```yaml\nname: ChatBot\non:\n  issue_comment:\n    # This shouldn't be called for comment deletion\n    types:\n      - created\n      - edited\n\njobs:\n  chatbot:\n    name: With latest code base\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Handle with Comvent\n        uses: rytswd/comvent@v0.3\n        id: comvent\n        with:\n          token: ${{ secrets.GITHUB_TOKEN }}\n          config-path: .github/comvent-chatbot.yaml\n\n      # The below only runs when Comvent finds matching comment.\n      # This assumes that Comvent config holding 'command-random' as a keyword.\n      - if: steps.comvent.outputs.command-random != ''\n        name: Handle random event\n        uses: actions/github-script@v3\n        with:\n          github-token: ${{ secrets.GITHUB_TOKEN }}\n          # An example of responding to a comment.\n          script: |\n            const comment = `Command \\`/random\\` was triggered by the comment`;\n\n            github.issues.createComment({\n              issue_number: context.issue.number,\n              owner: context.repo.owner,\n              repo: context.repo.repo,\n              body: comment\n            })\n\n      #\n      # You can repeat similar handling based on the Comvent config.\n      #\n```\n\n\u003c/details\u003e\n\nAs used above, Comvent configuration needs to define the keywords to find patterns.\n\n\u003e `.github/comvent-chatbot.yaml`\n\n```yaml\n---\nversion: 0.2.0\n\ntrigger: default\n\nkeywords:\n  - name: command-random\n    value: '^\\/random$' # Regex which looks for a comment with '/random'\n  - name: some-other-command\n    value: 'some arbitrary regex setup'\n\n  # You can have as many regex setup as you need.\n```\n\n### Handle Abusive Content\n\nYou can add a simple automation to monitor abusive comments.\n\nUsing [github-script](https://github.com/actions/github-script), you can automatically remove such comment when Comvent finds one, while leaving a comment about the deletion.\n\n\u003e `.github/workflows/abuse-monitor.yaml`\n\n```yaml\n- name: Handle with Comvent\n  uses: rytswd/comvent@v0.3\n  id: comvent\n  with:\n    token: ${{ secrets.GITHUB_TOKEN }}\n    config-path: .github/comvent-abuse-monitor.yaml\n\n# The below only runs when Comvent finds matching comment.\n# This assumes that Comvent config holding 'some-abusive-content' as a keyword.\n- if: steps.comvent.outputs.some-abusive-content != ''\n  name: Handle some abusive content\n  uses: actions/github-script@v3\n  with:\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n    # An example of removing the abusive comment, and leaving a comment about the deletion.\n    script: |\n      github.issues.deleteComment({\n        owner: context.repo.owner,\n        repo: context.repo.repo,\n        comment_id: ${{ github.event.comment.id }}\n      })\n\n      const comment = `Found abusive comment! 😰\n      The comment was thus removed.`;\n\n      github.issues.createComment({\n        issue_number: context.issue.number,\n        owner: context.repo.owner,\n        repo: context.repo.repo,\n        body: comment\n      })\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to view full example\u003c/summary\u003e\n\n\u003e `.github/workflows/abuse-monitor.yaml`\n\n```yaml\nname: Monitor Abusive Comments\non:\n  issue_comment:\n    # This shouldn't be called for comment deletion\n    types:\n      - created\n      - edited\n\njobs:\n  abuse-monitor:\n    name: With latest code base\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Handle with Comvent\n        uses: rytswd/comvent@v0.3\n        id: comvent\n        with:\n          token: ${{ secrets.GITHUB_TOKEN }}\n          config-path: .github/comvent-abuse-monitor.yaml\n\n      # The below only runs when Comvent finds matching comment.\n      # This assumes that Comvent config holding 'some-abusive-content' as a keyword.\n      - if: steps.comvent.outputs.some-abusive-content != ''\n        name: Handle some abusive content\n        uses: actions/github-script@v3\n        with:\n          github-token: ${{ secrets.GITHUB_TOKEN }}\n          # An example of removing the abusive comment, and leaving a comment about the deletion.\n          script: |\n            github.issues.deleteComment({\n              owner: context.repo.owner,\n              repo: context.repo.repo,\n              comment_id: ${{ github.event.comment.id }}\n            })\n\n            const comment = `Found abusive comment! 😰\n            The comment was thus removed.`;\n\n            github.issues.createComment({\n              issue_number: context.issue.number,\n              owner: context.repo.owner,\n              repo: context.repo.repo,\n              body: comment\n            })\n```\n\n\u003c/details\u003e\n\nAs used above, Comvent configuration needs to define the keywords to find patterns.\n\n\u003e `.github/comvent-abuse-monitor.yaml`\n\n```yaml\n---\nversion: 0.2.0\n\ntrigger: default\n\nkeywords:\n  - name: some-abusive-content\n    value: 'some abusive content' # Find abusive comment\n```\n\n## 🧪 Action Inputs\n\n| Name                | Description                                                                                                                                                                                                                               | IsRequired |\n| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------: |\n| `token`             | `GITHUB_TOKEN` or Personal Access Token with `repo` scope                                                                                                                                                                                 |    Yes     |\n| `config-path`       | Path to Comvent configuration file. You can find more about the configuration below. Defaults to `.github/comvent-setup.yaml`. Regardless of your GitHub Action setup, this assumes the current directory is the root of your repository. |            |\n| `config-check-only` | A flag to run only Comvent configuration setup. Used for testing only.                                                                                                                                                                    |            |\n\n## ⚙️ Comvent Configuration File\n\nComvent uses a dedicated YAML file for its configuration.\n\n### Example\n\nThe below is the copy of [`.github/comvent-setup.yaml`](https://github.com/rytswd/comvent/blob/main/.github/comvent-setup.yaml).\n\n```yaml\n---\n# version determines the supported values and how they are handled. The current\n# latest is 0.2.0, and if not speccified, it infers the latest version.\nversion: 0.2.0\n\n# trigger can accept either `default` or `specific`.\n# - default:  all comments will be handled by Comvent, except for those from\n#             users listed under users.inactive list below.\n# - specific: only comments made by specified users under users.active list\n#             below gets handled by Comvent.\ntrigger: default\n\n# users is consisted of `active` or `inactive` user list. Providing a list\n# which does not match the `trigger` setup above is simply ignored.\nusers:\n  active:\n    - rytswd # This is no-op, as the `trigger` above is set to `default`\n  inactive:\n    - random-user\n    - another-user\n\n# keywords is a list comprised of `name` and `value` fields.\n# - name:  used for Comvent output, and thus should not include whitespace.\n# - value: regex value to search for. The search takes place for each line in\n#          the comment.\nkeywords:\n  - name: command-random\n    value: '^\\/random$' # Regex which looks for a comment with '/random'\n```\n\nYou can find a few examples in [`.github/`](https://github.com/rytswd/comvent/tree/main/.github) directory.\n\n### Configuration Details\n\n| Key        | Description                                                                                                                                                                   | Default   |\n| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |\n| `version`  | The version of configuration spec. The latest is `0.2.0`. This may not be in line with the released version as of now, until Comvent releases v1.0                            | `0.2.0`   |\n| `trigger`  | When to handle Comvent. `default` means event triggered by anyone would be handled by Comvent, and `specific` means only specified users' comments would be handled.          | `default` |\n| `users`    | Stanza with `active` or `inactive` with list of GitHub user accounts. `active` list is only used for `specific` trigger setup, and `inactive` is for `default` trigger setup. |           |\n| `keywords` | Keywords to process comment based on. Each `value` is regex searched in comment, for each line.                                                                               |           |\n\n## 🍸 Action Outputs\n\nComvent provides the outputs with which you can tweak your Action worrkflow.\n\nAs the outputs will be based on the [Comvent Configuration File](#%EF%B8%8F-comvent-configuration-file) provided to Comvent, the below table is based on the following simple configuration as an example.\n\n\u003e `.github/comvent-config.yaml`\n\n```yaml\n---\nversion: 0.2.0\n\ntrigger: default\n\nkeywords:\n  - name: command-random\n    value: '^\\/random$'\n  - name: some-other-command\n    value: 'some arbitrary regex setup'\n  - name: command-echo\n    value: '^\\/echo (.+)$'\n```\n\n| Name                               | Description                                                                                                                                                                                                                                                                                                         |\n| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `comvent-found-any-match`          | Special keyword provided by Comvent by default. If any keyword is matched, this will provide `found` as output.                                                                                                                                                                                                     |\n| (Example)\u003cbr/\u003e`command-random`     | When the RegExp condition is matched, the entire line will be returned as the output. With the above example, this will be `/random`.                                                                                                                                                                               |\n| (Example)\u003cbr/\u003e`some-other-command` | When the RegExp condition is matched, the entire line will be returned as the output. With the above example, this will be something like `Test test - some arbitrary regex setup - test test`.                                                                                                                     |\n| (Example)\u003cbr/\u003e`command-echo`       | When the RegExp condition with group is matched, the first group match will be returned, and if the first group is an empty string, it would instead return the entire line. For example, with the above example, if the comment was `/echo this is a test message.`, the output will be `this is a test message.`. |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frytswd%2Fcomvent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frytswd%2Fcomvent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frytswd%2Fcomvent/lists"}