Giter Club home page Giter Club logo

commit-comment's Introduction

Commit Comment

CI GitHub Marketplace

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

Commit Comment Example

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.

      - name: Create commit comment
        uses: peter-evans/commit-comment@v3
        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

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

Add commit comment reactions

      - name: Add reactions
        uses: peter-evans/commit-comment@v3
        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.

      - name: Create commit comment
        uses: peter-evans/commit-comment@v3
        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

      - name: Create commit comment
        uses: peter-evans/commit-comment@v3
        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.

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

commit-comment's People

Contributors

actions-bot avatar chancancode avatar dependabot[bot] avatar nubpro avatar peter-evans avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

commit-comment's Issues

comment commit with output of something

Hi, I recently opened this help request in the comunity section, they told me I should probably have asked here so here I am.
Would you mind reading this and eventually tell me if something like that is possible?

TLDR: i would like to have a variable (output of a command i run in a job) in the body of the comments, is it possible?

Thanks in advance

Option to use an output file

I saw the other issue (#6) about the same thing but didn't get a working solution.

It would be great to have an option to use output files for comments. Something similar to the 'crrate-issue-from-file' action.

Github removed commit comment from the PR timeline

This is not really an "issue" of this project but today I just noticed that Github officially removed commit comment from the PR timeline.
https://github.blog/changelog/2022-08-04-commit-comments-no-longer-appear-in-the-pull-request-timeline/

timeline display was useful because I have been using this to generate and display the build/deploy info per commit.
While this is not a real issue of this project, I thought I'd share.
Please feel free to close this.

accept `body-path`

I have a similar issue as described peter-evans/create-or-update-comment#234 (comment)

Is it possible that this action also accepts body-path as an input

Im using the PR comment for the TF plan

And then im using the commit comment for the TF apply, this makes the apply even longer than the plan and it would be great if I could also pass it as a file, that was truncated if it goes to large

Documentation update: Use `head_ref` for comments on PR commits?

While omitting the sha action input just works for regular commits on branches, these comments are not visible when the action is run for pull requests.

The reason is that for pull requests, actions are run on "merge commits", as you explained here and also documented elsewhere.

By using

            -   uses: peter-evans/commit-comment@v1
                with:
                    body: "I'm sorry Dave, I'm afraid I can't do that."
                    sha: ${{ github.head_ref }}

... things seem to work for both PRs and regular commits.

If this makes sense, you might want to add a short notice in the README file?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.