• Stars
    star
    284
  • Rank 145,616 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

create comment on pull request, if exists update that comment.

Sticky Pull Request Comment

Create a comment on a pull request, if it 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

You need to add permissions for this tool.

permissions:
  pull-requests: write
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
    run: |
      EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
      echo "test_result<<$EOF" >> "$GITHUB_ENV"
      rake test >> "$GITHUB_ENV"
      echo "$EOF" >> "$GITHUB_ENV"
  - uses: marocchino/sticky-pull-request-comment@v2
    with:
      header: test
      message: |
        ```
        ${{ env.test_result }}
        ```

Append after comment every time it runs

test:
  ...
  - name: Run Test
    run: |
      EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
      echo "test_result<<$EOF" >> "$GITHUB_ENV"
      rake test >> "$GITHUB_ENV"
      echo "$EOF" >> "$GITHUB_ENV"
  - uses: marocchino/sticky-pull-request-comment@v2
    with:
      append: true
      message: |
        Test with ${{ github.sha }}.
        ```
        ${{ env.test_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 }} ended successfully.
      This message is from a push.

Read comment from a file

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

Delete the previous comment and add a comment at the end

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:
  header: <same-header-as-the-step-that-added-the-comment>
  delete: true

Hide the previous comment and add a comment at the end

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

Hide previous comment

uses: marocchino/sticky-pull-request-comment@v2
with:
  header: <same-header-as-the-step-that-added-the-comment>
  hide: true
  hide_classify: "OUTDATED"

Error: Resource not accessible by integration

This tool requires write permission, and that message means the requester does not have enough permission. Recently, GitHub sets permissions conservatively for newly created repositories. If it's a newly created repository, check your Settings > Actions > General > Workflow permissions, and make sure to enable read and write permissions.

Then, you can specify permissions for the job like this:

permissions:
  pull-requests: write

For more detailed information about permissions, you can read from the link below: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

Inputs

header

Optional Header to determine if the comment should be updated (it is not shown to users). It can be used when you want to add multiple comments independently to a given object.

append

Optional Indicate if new comment messages should be appended to previous comment message. Only true is allowed. Just skip this option 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 option when you don't need it.

delete

Optional Delete a previously created comment. Use header to point to which comment you want to delete. Only true is allowed (i.e. delete this option if you don't need it).

only_create

Optional Only create a new comment if there is no existing one, otherwise do nothing. Only true is allowed. Just skip this item when you don't need it. This options has higher priority than hide_and_recreate, hide.

only_update

Optional Only update a exist comment if there is existing one, otherwise do nothing. Only true is allowed. Just skip this item when you don't need it.

hide

Optional Hide a previously created comment. Use header to point to which comment you want to delete. Only true is allowed (i.e. delete this option if you don't need it).

hide_classify

Optional The reasons a piece of content can be reported or minimized. SPAM, ABUSE, OFF_TOPIC, OUTDATED, DUPLICATE, RESOLVED are available. default is OUTDATED.

hide_details

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

hide_and_recreate

Optional Indicate if previous comment should be removed before creating a new comment. Only true is allowed. Just skip this option 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. Note that this has a lower priority than the number of a pull_request event.

owner

Optional Another repository owner, If not set, the current repository owner is used by default. Note that when you trying changing a repo, be aware that GITHUB_TOKEN should also have permission for that repository.

repo

Optional Another repository name. Of limited use on GitHub enterprise. If not set, the current repository is used by default. Note that when you trying changing a repo, be aware that GITHUB_TOKEN should also have permission for that repository.

ignore_empty

Optional By default this is false. If set to true, no comment will be posted if the comment body is empty. Note that enabling this will prevent comment hiding & deletion from working when the body is empty.

GITHUB_TOKEN

Optional, You can set PAT here. If not set, this will use ${{ github.token }}.

Outputs

None

Any problem?

Feel free to report issues. ๐Ÿ˜ƒ

More Repositories

1

validate-dependabot

validate dependabot yaml
TypeScript
14
star
2

dotfiles

slate, bash, fish, tmux, nvim settings
Shell
14
star
3

tool-versions-action

output version numbers with .tool-versions file.
JavaScript
12
star
4

acommit

generate commit message with chatgpt api
Go
12
star
5

ffaker

elixir porting of https://github.com/ffaker/ffaker
Elixir
9
star
6

pipe_converter

A vim plugin that convert your nested functions into pipe operators
Elixir
7
star
7

setup-terraform

Set up your GitHub Actions workflow with a specific version of terraform
JavaScript
6
star
8

ruby-check-action

Run ruby -wc in github action
TypeScript
5
star
9

setup-ecs-cli

Setup a ecs-cli environment and add it to the PATH
JavaScript
5
star
10

simplecov-formatter-badge

Ruby
3
star
11

jipcode

jipcode porting from ruby
TypeScript
3
star
12

chamber

open feedback system for collaboration
Ruby
2
star
13

selector-normalizer

JavaScript
2
star
14

refactoring-ruby-edition

๋ฆฌํŒฉํ† ๋ง ๋ฃจ๋น„ ์—๋””์…˜ ์†Œ์Šค์ฝ”๋“œ (๋น„๊ณต์‹)
Ruby
2
star
15

python-basic

python ๅ‹‰ๅผทไผšใฎ study codes
Python
2
star
16

on_artifact

Optimized for workflow_run. Download artifact and set as output then clear it
TypeScript
2
star
17

waldo

๋‚˜๋Š” ๋งŒ๋“ค์—ˆ๋‹ค ์ €์žฅ์†Œ๋ฅผ
Elixir
2
star
18

list_to_csv

Convert a list of nested maps to `list(list(String.t))` or CSV. Can be used with GraphQL.
Elixir
1
star
19

handsup

Elixir
1
star
20

openapi_to_graphql

Elixir
1
star
21

korean_foreign_spell_dictionary

์™ธ๋ž˜์–ด ํ‘œ๊ธฐ๋ฒ• ์‚ฌ์ „
Ruby
1
star
22

korean-typo-highlighter.vim

ํ‹€๋ฆฐ ์™ธ๋ž˜์–ด๋ฅผ ํ•˜์ด๋ผ์ดํŒ… ํ•ด์ค๋‹ˆ๋‹ค.
Vim Script
1
star
23

acommit.nvim

Lua
1
star
24

graphql-server-studies

Sample code for in-house studies
JavaScript
1
star
25

postcss-kebab-case-selector

PostCSS plugin that normalize all css name to kebab case
JavaScript
1
star
26

checkbox-action

Checks or unchecks a checkbox in the body of the pull request, or returns the list confirming the change in the checkbox.
TypeScript
1
star