Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

commit-comment

> 开发工具
Open source

A GitHub action to create a comment for a commit on GitHub

99 stars0 likes0 views
WebsiteGitHub

About

A GitHub action to create a comment for a commit on GitHub

Commit Comment

A GitHub action to create a comment for a commit on GitHub.

Usage

Add a comment to the current context's commit SHA

The SHA defaults to github.sha OR, for pull_request events github.event.pull_request.head.sha.

yaml
      - name: Create commit comment
        uses: peter-evans/commit-comment@v4
        with:
          body: |
            This is a multi-line test comment
            - With GitHub **Markdown** :sparkles:
            - Created by [commit-comment][1]

            [1]: https://github.com/peter-evans/commit-comment
          reactions: '+1'

Update a commit comment

yaml
      - name: Update commit comment
        uses: peter-evans/commit-comment@v4
        with:
          comment-id: 557858210
          body: |
            **Edit:** Some additional info
          reactions: eyes

Add commit comment reactions

yaml
      - name: Add reactions
        uses: peter-evans/commit-comment@v4
        with:
          comment-id: 557858210
          reactions: |
            heart
            hooray
            laugh

Action inputs

Name Description Default
token GITHUB_TOKEN or a repo scoped PAT. GITHUB_TOKEN
repository The full name of the target repository. github.repository (current repository)
sha The commit SHA. github.sha OR, for pull_request events github.event.pull_request.head.sha
path Relative path of the file to comment on.
position Line index in the diff to comment on.
comment-id The id of the comment to update.
body The comment body. Cannot be used in conjunction with body-path.
body-path The path to a file containing the comment body. Cannot be used in conjunction with body.
edit-mode The mode when updating a comment, replace or append. append
append-separator The separator to use when appending to an existing comment. (newline, space, none) newline
reactions A comma or newline separated list of reactions to add to the comment. (+1, -1, laugh, confused, heart, hooray, rocket, eyes)
reactions-edit-mode The mode when updating comment reactions, replace or append. append

Note: In public repositories this action does not work in pull_request workflows when triggered by forks. Any attempt will be met with the error, Resource not accessible by integration. This is due to token restrictions put in place by GitHub Actions. Private repositories can be configured to enable workflows from forks to run without restriction. See here for further explanation. Alternatively, use the pull_request_target event to comment on pull request commits.

Outputs

The ID of the created comment will be output for use in later steps. Note that in order to read the step output the action step must have an id.

yaml
      - name: Create commit comment
        uses: peter-evans/commit-comment@v4
        id: cc
        with:
          body: |
            My comment
      - name: Check outputs
        run: |
          echo "Comment ID - ${{ steps.cc.outputs.comment-id }}"

Setting the comment body from a file

yaml
      - name: Create commit comment
        uses: peter-evans/commit-comment@v4
        with:
          body-path: 'comment-body.md'

Using a markdown template

In this example, a markdown template file is added to the repository at .github/comment-template.md with the following content.

This is a test comment template
Render template variables such as {{ .foo }} and {{ .bar }}.

The template is rendered using the render-template action and the result is used to create the comment.

yaml
      - name: Render template
        id: template
        uses: chuhlomin/[email protected]
        with:
          template: .github/comment-template.md
          vars: |
            foo: this
            bar: that

      - name: Create commit comment
        uses: peter-evans/commit-comment@v4
        with:
          body: ${{ steps.template.outputs.result }}

Accessing commits and comments in other repositories

You can create and update commit comments in another repository by using a PAT instead of GITHUB_TOKEN. The user associated with the PAT must have write access to the repository.

License

MIT

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptcommit-commentgithub-actionsgithub-api

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具