Giter VIP home page Giter VIP logo

comment-pull-request's Introduction

CI

Comment Pull Request

A GitHub Action for commenting on pull requests from workflows. Previous comments by the same job are deleted (or hidden or edited), thus avoiding flooding reports of checks based on old commits.

Usage

See action.yml for available action inputs. Note that this action requires pull-requests: write permission.

Supported workflow trigger events

Basically, this action is used in pull_request events, but you can use it in any trigger by specifying pull-request-number input (default is ${{ github.event.pull_request.number }}).

Even if this input is omitted, the pull request number will be searched for using the commit SHA specified in sha input (default is ${{ github.sha }}), but if it cannot be found, explicitly specify pull-request-number input. For example, in the case of merge queue, you cannot search using ${{ github.sha }}, so do it like this.

Basic

Specify comment input.

- uses: yumemi-inc/comment-pull-request@v1
  with:
    comment: |
      # Test coverage report

      ...

In this case, previous comments will be deleted.

Change how previous comments are handled

By specifying previous-comment input, you can change the handling of previous comments. Specify one of delete (default), hide, edit, or keep (do nothing).

- uses: yumemi-inc/comment-pull-request@v1
  with:
    previous-comment: 'hide'
    comment: |
      # Test coverage report

      ...

Comments are grouped by the value of grouping-key input (default is ${{ github.workflow }}-${{ github.job }}), and comments in the same group are subject to deletion, etc.

Comments on failure

It is often necessary to separate the contents of comments when a check passes and when it fails. You can define it in one step by using comment-if-failure input.

- run: npm run test
- uses: yumemi-inc/comment-pull-request@v1
  if: cancelled() != true
  with:
    comment: |
      :white_check_mark: All tests passed.
    comment-if-failure: |
      :no_entry_sign: Some tests failed.
      
      See test results from ...

Fail workflows for CI

If you want the workflow to fail along with the comment, specify true for fail input.

Tips

Comment file contents

Sample workflow for commenting file contents.

- id: sample
  run: |
    ls -al > ./sample.txt
    {
      delimiter="$(openssl rand -hex 8)"
      echo "file<<$delimiter"
      cat ./sample.txt
      echo "$delimiter"
    } >> "$GITHUB_OUTPUT"
- uses: yumemi-inc/comment-pull-request@v1
  with:
    comment: |
      <details>
      <summary>sample.txt</summary>

      ${{ steps.sample.outputs.file }}
      </details>

ref: Multiline strings

User mention

Write the account name after @. For example, to mention the creator of a pull request, write as follows:

comment: |
  @${{ github.actor }} A critical error has occurred.

Guide to job logs and summaries

The URL for the job log and summary is https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.

To guide this URL with comments, write as follows;

comment: |
  Some tests failed.

  See details from [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).

It is recommended to write reports such as test results and coverage in the summary rather than in comments.

comment-pull-request's People

Contributors

hkusu avatar

Stargazers

KAWASHIMA Yoshiyuki avatar

Watchers

watanave avatar  avatar Hiroki Naito avatar  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.