Git Product home page Git Product logo

sticky-pull-request-comment's Introduction

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

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 }} 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 message means the requester does not have enough permission. If secrets.GITHUB_TOKEN is explicitly passed, this problem can be solved by just removing it.

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).

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.

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.

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. 😃

sticky-pull-request-comment's People

Contributors

marocchino avatar dependabot[bot] avatar dependabot-preview[bot] avatar jakemhiller avatar svanboxel avatar jawnsy avatar ssboisen avatar adyyoung avatar backspace avatar fddayan avatar gunar avatar jsoref avatar msbarry avatar rcowsill avatar

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.