Comment on pull requests

With Reviewpad, you can automatically add comments to the pull request.

There are three different mechanisms to add a comment to the pull request:

  1. Using the comment action.
  2. Using the commentOnce action.
  3. Using the error, info or warn actions.

The difference between the modes is that the comment action will add a comment every time the action is executed, commentOnce will add a comment once no matter the amount of times the action is executed, while the other commenting actions are bundled together in a comment which is also automatically updated.

To the use the third set of comments (i.e. error, warn and info) you need to enable the professional edition.

Automatically comment the pull request.


edition: professional

mode: verbose

  - name: tautology
    kind: patch
    description: tautology
    spec: "true"

  - name: emptyDescription
    kind: patch
    description: empty description
    spec: '$description() == ""'

  - name: isFirstTimeContributor
    kind: patch
    description: first pull request
    spec: "$totalCreatedPullRequests($author()) == 1"

  - name: welcome-user
    description: Welcome user first contribution
      - rule: isFirstTimeContributor
      # Comment on pull request once
      - '$commentOnce("Well done! This is your first contribution.")'

  - name: comment-on-pull-request
    description: Example comment on pull request
      - rule: tautology
      # Add info message to reviewpad report
      - $info("Thanks for this pull request. @marcelosousa will take a look!")
      # Add warning message to reviewpad report
      - $warn("Please make sure the CI is green before merging.")

  - name: comment-on-empty-description
    description: Error on empty descriptions
    always-run: true
      - rule: emptyDescription
      # Add error message to reviewpad report
      - $error("The description of the pull request cannot be empty")

You can see this workflow in action the following pull request.

Did this page help you?