A GitHub action to create or update an issue or pull request comment
Go to file
Peter Evans 7032041582
Merge pull request #31 from peter-evans/renovate/jest-monorepo
Update dependency jest to v25.5.0
2020-04-29 08:08:12 +09:00
.github/workflows Update workflow 2020-04-17 16:47:21 +09:00
dist Deprecate reaction-type in favour of reactions 2020-04-17 16:31:30 +09:00
.eslintrc.json Add action 2019-11-24 16:44:26 +09:00
.gitignore Add action 2019-11-24 16:44:26 +09:00
action.yml Deprecate reaction-type in favour of reactions 2020-04-17 16:31:30 +09:00
index.js Deprecate reaction-type in favour of reactions 2020-04-17 16:31:30 +09:00
LICENSE Initial commit 2019-11-24 16:35:05 +09:00
package-lock.json Update dependency jest to v25.5.0 2020-04-28 20:06:14 +00:00
package.json Update dependency jest to v25.5.0 2020-04-28 20:06:14 +00:00
README.md Deprecate reaction-type in favour of reactions 2020-04-17 16:31:30 +09:00
renovate.json Add renovate.json 2020-01-23 00:17:30 +00:00

Create or Update Comment

GitHub Marketplace

A GitHub action to create or update an issue or pull request comment.

This action was created to help facilitate a GitHub Actions "ChatOps" solution in conjunction with slash-command-dispatch action.

Usage

Add a comment to an issue or pull request

      - name: Create comment
        uses: peter-evans/create-or-update-comment@v1
        with:
          issue-number: 1
          body: |
            This is a multi-line test comment
            - With GitHub **Markdown**
            - Created by [create-or-update-comment][1]

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

Update a comment

      - name: Update comment
        uses: peter-evans/create-or-update-comment@v1
        with:
          comment-id: 557858210
          body: |
            **Edit:** Some additional info            
          reactions: eyes

Add comment reactions

      - name: Add reactions
        uses: peter-evans/create-or-update-comment@v1
        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 repository in which to create or update a comment. Current repository
issue-number The number of the issue or pull request in which to create a comment.
comment-id The id of the comment to update.
body The comment body.
edit-mode The mode when updating a comment, replace or append. append
reactions A comma separated list of reactions to add to the comment. (+1, -1, laugh, confused, heart, hooray, rocket, eyes)

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 comment
        uses: peter-evans/create-or-update-comment@v1
        id: couc
        with:
          issue-number: 1
          body: |
            My comment            
      - name: Check outputs
        run: |
          echo "Comment ID - ${{ steps.couc.outputs.comment-id }}"          

Where to find the id of a comment

How to find the id of a comment will depend a lot on the use case. Here is one example where the id can be found in the github context during an issue_comment event.

on:
  issue_comment:
    types: [created]
jobs:
  commentCreated:
    runs-on: ubuntu-latest
    steps:
      - name: Add reaction
        uses: peter-evans/create-or-update-comment@v1
        with:
          comment-id: ${{ github.event.comment.id }}
          reactions: eyes

Accessing issues and comments in other repositories

You can create and update 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