{"id":13731918,"url":"https://github.com/peter-evans/create-or-update-comment","last_synced_at":"2025-05-13T15:13:27.708Z","repository":{"id":37870532,"uuid":"223708643","full_name":"peter-evans/create-or-update-comment","owner":"peter-evans","description":"A GitHub action to create or update an issue or pull request comment","archived":false,"fork":false,"pushed_at":"2025-05-07T05:26:48.000Z","size":2412,"stargazers_count":799,"open_issues_count":7,"forks_count":133,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-08T20:43:32.526Z","etag":null,"topics":["comment-reactions","github-action","github-comments","github-issues"],"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/peter-evans.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"github":"peter-evans"}},"created_at":"2019-11-24T07:35:04.000Z","updated_at":"2025-05-08T18:37:02.000Z","dependencies_parsed_at":"2023-10-19T16:28:53.915Z","dependency_job_id":"b1a55bb8-3086-4721-98b6-c7124725db1d","html_url":"https://github.com/peter-evans/create-or-update-comment","commit_stats":{"total_commits":353,"total_committers":13,"mean_commits":"27.153846153846153","dds":0.4447592067988668,"last_synced_commit":"d5aa8cd1ea450824d5ae23e44f55efc071b98b44"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fcreate-or-update-comment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fcreate-or-update-comment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fcreate-or-update-comment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fcreate-or-update-comment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peter-evans","download_url":"https://codeload.github.com/peter-evans/create-or-update-comment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253376605,"owners_count":21898930,"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":["comment-reactions","github-action","github-comments","github-issues"],"created_at":"2024-08-03T02:01:41.464Z","updated_at":"2025-05-13T15:13:22.689Z","avatar_url":"https://github.com/peter-evans.png","language":"TypeScript","funding_links":["https://github.com/sponsors/peter-evans"],"categories":["TypeScript","JavaScript"],"sub_categories":[],"readme":"# Create or Update Comment\n[![CI](https://github.com/peter-evans/create-or-update-comment/workflows/CI/badge.svg)](https://github.com/peter-evans/create-or-update-comment/actions?query=workflow%3ACI)\n[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-Create%20or%20Update%20Comment-blue.svg?colorA=24292e\u0026colorB=0366d6\u0026style=flat\u0026longCache=true\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAM6wAADOsB5dZE0gAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAERSURBVCiRhZG/SsMxFEZPfsVJ61jbxaF0cRQRcRJ9hlYn30IHN/+9iquDCOIsblIrOjqKgy5aKoJQj4O3EEtbPwhJbr6Te28CmdSKeqzeqr0YbfVIrTBKakvtOl5dtTkK+v4HfA9PEyBFCY9AGVgCBLaBp1jPAyfAJ/AAdIEG0dNAiyP7+K1qIfMdonZic6+WJoBJvQlvuwDqcXadUuqPA1NKAlexbRTAIMvMOCjTbMwl1LtI/6KWJ5Q6rT6Ht1MA58AX8Apcqqt5r2qhrgAXQC3CZ6i1+KMd9TRu3MvA3aH/fFPnBodb6oe6HM8+lYHrGdRXW8M9bMZtPXUji69lmf5Cmamq7quNLFZXD9Rq7v0Bpc1o/tp0fisAAAAASUVORK5CYII=)](https://github.com/marketplace/actions/create-or-update-comment)\n\nA GitHub action to create or update an issue or pull request comment.\n\n## Usage\n\n### Add a comment to an issue or pull request\n\n```yml\n      - name: Create comment\n        uses: peter-evans/create-or-update-comment@v4\n        with:\n          issue-number: 1\n          body: |\n            This is a multi-line test comment\n            - With GitHub **Markdown** :sparkles:\n            - Created by [create-or-update-comment][1]\n\n            [1]: https://github.com/peter-evans/create-or-update-comment\n          reactions: '+1'\n```\n\n### Update a comment\n\n```yml\n      - name: Update comment\n        uses: peter-evans/create-or-update-comment@v4\n        with:\n          comment-id: 557858210\n          body: |\n            **Edit:** Some additional info\n          reactions: eyes\n```\n\n### Add comment reactions\n\n```yml\n      - name: Add reactions\n        uses: peter-evans/create-or-update-comment@v4\n        with:\n          comment-id: 557858210\n          reactions: |\n            heart\n            hooray\n            laugh\n```\n\n### Action inputs\n\n| Name | Description | Default |\n| --- | --- | --- |\n| `token` | `GITHUB_TOKEN` (`issues: write`, `pull-requests: write`) or a `repo` scoped [PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). | `GITHUB_TOKEN` |\n| `repository` | The full name of the repository in which to create or update a comment. | Current repository |\n| `issue-number` | The number of the issue or pull request in which to create a comment. | |\n| `comment-id` | The id of the comment to update. | |\n| `body` | The comment body. Cannot be used in conjunction with `body-path`. | |\n| `body-path` | The path to a file containing the comment body. Cannot be used in conjunction with `body`. | |\n| `edit-mode` | The mode when updating a comment, `replace` or `append`. | `append` |\n| `append-separator` | The separator to use when appending to an existing comment. (`newline`, `space`, `none`) | `newline` |\n| `reactions` | A comma or newline separated list of reactions to add to the comment. (`+1`, `-1`, `laugh`, `confused`, `heart`, `hooray`, `rocket`, `eyes`) | |\n| `reactions-edit-mode` | The mode when updating comment reactions, `replace` or `append`. | `append` |\n\nNote: In *public* repositories this action does not work in `pull_request` workflows when triggered by forks.\nAny attempt will be met with the error, `Resource not accessible by integration`.\nThis is due to token restrictions put in place by GitHub Actions. Private repositories can be configured to [enable workflows](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#enabling-workflows-for-forks-of-private-repositories) from forks to run without restriction. See [here](https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#restrictions-on-repository-forks) for further explanation. Alternatively, use the [`pull_request_target`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target) event to comment on pull requests.\n\n#### Outputs\n\nThe ID of the created comment will be output for use in later steps.\nNote that in order to read the step output the action step must have an id.\n\n```yml\n      - name: Create comment\n        uses: peter-evans/create-or-update-comment@v4\n        id: couc\n        with:\n          issue-number: 1\n          body: |\n            My comment\n      - name: Check outputs\n        run: |\n          echo \"Comment ID - ${{ steps.couc.outputs.comment-id }}\"\n```\n\n### Where to find the id of a comment\n\nHow to find the id of a comment will depend a lot on the use case.\nHere is one example where the id can be found in the `github` context during an `issue_comment` event.\n\n```yml\non:\n  issue_comment:\n    types: [created]\njobs:\n  commentCreated:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Add reaction\n        uses: peter-evans/create-or-update-comment@v4\n        with:\n          comment-id: ${{ github.event.comment.id }}\n          reactions: eyes\n```\n\nSome use cases might find the [find-comment](https://github.com/peter-evans/find-comment) action useful.\nThis will search an issue or pull request for the first comment containing a specified string, and/or by a specified author.\nSee the repository for detailed usage.\n\nIn the following example, find-comment is used to determine if a comment has already been created on a pull request.\nIf the find-comment action output `comment-id` returns an empty string, a new comment will be created.\nIf it returns a value, the comment already exists and the content is replaced.\n```yml\n    - name: Find Comment\n      uses: peter-evans/find-comment@v3\n      id: fc\n      with:\n        issue-number: ${{ github.event.pull_request.number }}\n        comment-author: 'github-actions[bot]'\n        body-includes: Build output\n\n    - name: Create or update comment\n      uses: peter-evans/create-or-update-comment@v4\n      with:\n        comment-id: ${{ steps.fc.outputs.comment-id }}\n        issue-number: ${{ github.event.pull_request.number }}\n        body: |\n          Build output\n          ${{ steps.build.outputs.build-log }}\n        edit-mode: replace\n```\n\nIf required, the create and update steps can be separated for greater control.\n```yml\n    - name: Find Comment\n      uses: peter-evans/find-comment@v3\n      id: fc\n      with:\n        issue-number: ${{ github.event.pull_request.number }}\n        comment-author: 'github-actions[bot]'\n        body-includes: This comment was written by a bot!\n\n    - name: Create comment\n      if: steps.fc.outputs.comment-id == ''\n      uses: peter-evans/create-or-update-comment@v4\n      with:\n        issue-number: ${{ github.event.pull_request.number }}\n        body: |\n          This comment was written by a bot!\n        reactions: rocket\n\n    - name: Update comment\n      if: steps.fc.outputs.comment-id != ''\n      uses: peter-evans/create-or-update-comment@v4\n      with:\n        comment-id: ${{ steps.fc.outputs.comment-id }}\n        body: |\n          This comment has been updated!\n        reactions: hooray\n```\n\n### Setting the comment body from a file\n\n```yml\n      - name: Create comment\n        uses: peter-evans/create-or-update-comment@v4\n        with:\n          issue-number: 1\n          body-path: 'comment-body.md'\n```\n\n### Using a markdown template\n\nIn this example, a markdown template file is added to the repository at `.github/comment-template.md` with the following content.\n```\nThis is a test comment template\nRender template variables such as {{ .foo }} and {{ .bar }}.\n```\n\nThe template is rendered using the [render-template](https://github.com/chuhlomin/render-template) action and the result is used to create the comment.\n```yml\n      - name: Render template\n        id: template\n        uses: chuhlomin/render-template@v1.4\n        with:\n          template: .github/comment-template.md\n          vars: |\n            foo: this\n            bar: that\n\n      - name: Create comment\n        uses: peter-evans/create-or-update-comment@v4\n        with:\n          issue-number: 1\n          body: ${{ steps.template.outputs.result }}\n```\n\n### Accessing issues and comments in other repositories\n\nYou can create and update comments in another repository by using a [PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) instead of `GITHUB_TOKEN`.\nThe user associated with the PAT must have write access to the repository.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-evans%2Fcreate-or-update-comment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeter-evans%2Fcreate-or-update-comment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-evans%2Fcreate-or-update-comment/lists"}