create comment on pull request, if exists update that comment.
Find a file
marocchino 56ac27318d
refactor: extract config (#257)
* refactor: extract config

* test: mock dynamic value
2021-03-22 09:39:18 +09:00
.github/workflows docs: omit github token in docs 2021-03-22 06:32:32 +09:00
__tests__ refactor: extract config (#257) 2021-03-22 09:39:18 +09:00
dist refactor: extract config (#257) 2021-03-22 09:39:18 +09:00
lib refactor: extract config (#257) 2021-03-22 09:39:18 +09:00
src refactor: extract config (#257) 2021-03-22 09:39:18 +09:00
.eslintignore update setup 2021-02-25 16:21:42 +09:00
.eslintrc.json update setup 2021-02-25 16:21:42 +09:00
.gitattributes ignore dist diff 2021-02-25 16:23:38 +09:00
.gitignore chore: ignore vscode setting 2019-11-23 10:43:26 +09:00
.prettierignore update setup 2021-02-25 16:21:42 +09:00
.prettierrc.json update setup 2021-02-25 16:21:42 +09:00
.tool-versions update node 2021-01-21 07:43:05 +09:00
action.yml refactor: extract config (#257) 2021-03-22 09:39:18 +09:00
jest.config.js Initial commit 2019-11-21 08:05:13 +09:00
LICENSE Initial commit 2019-11-21 08:05:13 +09:00
package-lock.json build(deps-dev): bump @types/jest from 26.0.20 to 26.0.21 2021-03-17 20:20:32 +00:00
package.json build(deps-dev): bump @types/jest from 26.0.20 to 26.0.21 2021-03-17 20:20:32 +00:00
README.md docs: omit github token in docs 2021-03-22 06:32:32 +09:00
tsconfig.json update setup 2021-02-25 16:21:42 +09:00
wallaby.js chore: wallaby config 2019-11-23 10:10:39 +09:00

Sticky Pull Request Comment

Create comment on pull request, if exists update that comment. This library runs with GitHub Actions. If you feel that the example grammar below is not friendly enough, we recommend reading this page first.

Usage

Basic

uses: marocchino/sticky-pull-request-comment@v2
with:
  message: |
    Release ${{ github.sha }} to <https://pr-${{ github.event.number }}.example.com>    

Keep more than one comment

In some cases, different actions may require different comments. The header allows you to maintain comments independently.

release:
  ...
  - uses: marocchino/sticky-pull-request-comment@v2
    with:
      header: release
      message: |
        Release ${{ github.sha }} to <https://pr-${{ github.event.number }}.example.com>        

test:
  ...
  - name: Run Test
    id: test
    run: |
      OUTPUT=$(rake test)
      OUTPUT="${OUTPUT//'%'/'%25'}【7,6 m】"
      OUTPUT="${OUTPUT//$'\n'/'%0A'}"
      OUTPUT="${OUTPUT//$'\r'/'%0D'}"
      echo "::set-output name=result::$OUTPUT"      
  - uses: marocchino/sticky-pull-request-comment@v2
    with:
      header: test
      message: |
        ```
        ${{ steps.test.outputs.result }}
        ```        

Append after comment every time it runs

test:
  ...
  - name: Run Test
    id: test
    run: |
      OUTPUT=$(rake test)
      OUTPUT="${OUTPUT//'%'/'%25'}【7,6 m】"
      OUTPUT="${OUTPUT//$'\n'/'%0A'}"
      OUTPUT="${OUTPUT//$'\r'/'%0D'}"
      echo "::set-output name=result::$OUTPUT"      
  - uses: marocchino/sticky-pull-request-comment@v2
    with:
      append: true
      message: |
        Test with ${{ github.sha }}.
        ```
        ${{ steps.test.outputs.result }}
        ```        

Comment from push

If for some reason, triggering on pr is not possible, you can use push.

- uses: jwalton/gh-find-current-pr@v1
  id: finder
- uses: marocchino/sticky-pull-request-comment@v2
  with:
    number: ${{ steps.finder.outputs.pr }}
    message: |
      Test ${{ github.sha }} is successfully ended.
      This is message from push.      

Read comment from a file

uses: marocchino/sticky-pull-request-comment@v2
with:
  path: path-to-comment-contents.txt

Delete previous commit and add comment at bottom

uses: marocchino/sticky-pull-request-comment@v2
with:
  recreate: true
  message: |
    Release ${{ github.sha }} to <https://pr-${{ github.event.number }}.example.com>    

Delete previous comment

uses: marocchino/sticky-pull-request-comment@v2
with:
  delete: true

Inputs

header

Optional Header to determine if the comment is to be updated, not shown on screen. It can be used when you want to add multiple comments independently at the same time.

append

Optional Indicate if new comment messages should be appended to previous comment message. Only true is allowed. Just skip this item when you don't need it.

recreate

Optional Indicate if previous comment should be removed before creating a new comment. Only true is allowed. Just skip this item when you don't need it.

delete

Optional delete the previously created comment. Only true is allowed. Just skip this item when you don't need it.

message

Optional comment message

path

Optional path to file containing comment message

number

Optional pull request number for push event

repo

Optional other repo name limited use on github enterprise. If not set, the current repo is used by default. Note that When you trying changing a repo, be aware that GITHUB_TOKEN should also use that repo's.

GITHUB_TOKEN

Optional, typically set secrets.GITHUB_TOKEN. If not set, this will use ${{ github.token }}.

Outputs

no outputs

Any problem?

Feel free to report issues. 😃