Comment Action
Add or update comments on pull requests
The Comment Action allows you to automatically add or update comments on pull requests based on validation results. This is useful for providing feedback, instructions, or information to PR authors and reviewers.
Configuration
The content of the comment to add to the PR
Whether to create a new comment (true) or update an existing one (false)
Basic Usage
Examples
Simple Comment
Add a basic comment when validations fail:
Detailed Feedback with Template Variables
Provide detailed feedback using template variables:
Updating Existing Comments
Update the bot’s previous comment instead of creating a new one:
Conditional Success Messages
Provide positive feedback when validations pass:
Template Variables
The Comment Action supports these template variables:
Variable | Description |
---|---|
{{ pull_request.user.login }} | PR author’s username |
{{ pull_request.title }} | PR title |
{{ pull_request.body }} | PR description |
{{ pull_request.number }} | PR number |
{{ repository.name }} | Repository name |
{{ repository.full_name }} | Full repository name (owner/repo) |
{{ validation_summary }} | Summary of all validation results |
How It Works
Process Template
The action processes the comment body, replacing template variables with actual values
Check Settings
If create_new
is false, it looks for a previous comment from the Rulesets bot
Update or Create
If an existing bot comment is found (and create_new
is false), it updates that comment; otherwise, it creates a new comment
Practical Use Cases
Onboarding New Contributors
Provide guidance to first-time contributors:
CI Failure Summary
Summarize CI failures to save time:
Labeling Explanation
Explain why certain labels were added:
Best Practices
create_new: false
to avoid cluttering PRs with multiple similar commentsAvoid making comments too verbose or adding them too frequently, as this can be perceived as noisy
Limitations
- Comments are always posted from the GitHub App’s account
- Markdown formatting in comments is limited to what GitHub supports
- Template variables are limited to those provided by Rulesets