create comment on pull request, if exists update that comment.
Find a file
marocchino 6804b5ad49
Merge pull request #186 from marocchino/dependabot/npm_and_yarn/types/node-14.11.8
build(deps-dev): bump @types/node from 14.11.5 to 14.11.8
2020-10-12 08:31:49 +09:00
.github/workflows build: build custom header implement 2020-02-04 17:24:40 +09:00
__tests__ Merge branch 'master' into replace-option 2020-06-25 14:51:01 +09:00
lib Add support for deleting previously created comments 2020-10-11 19:29:41 +02:00
node_modules build(deps): commit production deps 2019-11-21 10:11:11 +09:00
src Add support for deleting previously created comments 2020-10-11 19:29:41 +02:00
.gitignore chore: ignore vscode setting 2019-11-23 10:43:26 +09:00
.tool-versions build: update deps 2020-06-04 06:45:51 +09:00
action.yml docs: update README 2020-10-12 08:31:08 +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/node from 14.11.5 to 14.11.8 2020-10-10 08:15:01 +00:00
package.json build(deps-dev): bump @types/node from 14.11.5 to 14.11.8 2020-10-10 08:15:01 +00:00
README.md docs: update README 2020-10-12 08:31:08 +09:00
tsconfig.json Initial commit 2019-11-21 08:05:13 +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.

Usage:

Basic

uses: marocchino/sticky-pull-request-comment@v1
with:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  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@v1
  with:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    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@v1
  with:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    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@v1
  with:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    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
with:
  github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: marocchino/sticky-pull-request-comment@v1
with:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  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@v1
with:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  path: path-to-comment-contents.txt

Delete previous commit and add comment at bottom

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

Delete previous commit

uses: marocchino/sticky-pull-request-comment@v1
with:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  delete: true

Development

Install the dependencies

$ npm install

Build the typescript

$ npm run build

Run the tests ✔️

$ npm test

 PASS  ./index.test.js
  ✓ throws invalid number (3ms)wait 500 ms (504ms)test runs (95ms)

...

Publish to a distribution branch

Actions are run from GitHub repos. We will create a releases branch and only checkin production modules (core in this case).

Comment out node_modules in .gitignore and create a releases/v1 branch

# comment out in distribution branches
# node_modules/
$ git checkout -b releases/v1
$ git commit -a -m "prod dependencies"
$ npm prune --production
$ git add node_modules
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1

Your action is now published! 🚀

See the versioning documentation