A GitHub Action to add or update comments on Pull Requests and Issues with support for comment deduplication using unique message IDs.
- Add comments to PRs and Issues
- Update existing comments using a unique message ID
- Automatic comment truncation for large messages
- Works in pull_request, issue, and other workflow contexts
- Simple, focused API
- uses: flxbl-io/add-comment@v1
with:
message: |
## Build Results
Build completed successfully!
token: ${{ secrets.GITHUB_TOKEN }}Using message-id ensures that subsequent runs update the same comment instead of creating duplicates:
- uses: flxbl-io/add-comment@v1
with:
message: |
## Deployment Status
Deployed to production at ${{ github.event.head_commit.timestamp }}
message-id: deployment-status
token: ${{ secrets.GITHUB_TOKEN }}- uses: flxbl-io/add-comment@v1
with:
message: 'This is related to the current work.'
issue-number: 123
token: ${{ secrets.GITHUB_TOKEN }}- uses: flxbl-io/add-comment@v1
with:
message: 'Cross-repo notification'
issue-number: 456
repository: owner/other-repo
token: ${{ secrets.PAT_TOKEN }}| Input | Description | Required | Default |
|---|---|---|---|
message |
The message content to post as a comment (supports Markdown) | Yes | - |
issue-number |
The issue or pull request number to comment on | No | Auto-detected from context |
pr-number |
Alias for issue-number (for pull request context) | No | Auto-detected from context |
repository |
The repository in owner/repo format | No | ${{ github.repository }} |
token |
GitHub token for API authentication | No | ${{ github.token }} |
message-id |
Unique identifier for the comment. Used to find and update existing comments instead of creating duplicates | No | - |
| Output | Description |
|---|---|
comment-id |
The ID of the created or updated comment |
comment-created |
Whether a new comment was created (true/false) |
comment-updated |
Whether an existing comment was updated (true/false) |
- uses: flxbl-io/add-comment@v1
if: always()
with:
message: |
## CI Status: ${{ job.status }}
${{ job.status == 'success' && 'All checks passed!' || 'Some checks failed.' }}
message-id: ci-status
token: ${{ secrets.GITHUB_TOKEN }}- uses: flxbl-io/add-comment@v1
with:
message: |
## Test Results
| Metric | Value |
|--------|-------|
| Tests Run | 150 |
| Passed | 148 |
| Failed | 2 |
<details>
<summary>Failed Tests</summary>
- `test_login_flow`
- `test_checkout_process`
</details>
message-id: test-results
token: ${{ secrets.GITHUB_TOKEN }}When you provide a message-id, the action:
- Searches existing comments on the issue/PR for a hidden marker
- If found, updates that comment with the new message
- If not found, creates a new comment with the marker
This prevents duplicate comments when workflows run multiple times.
GitHub has a 64KB limit on comment size. If your message exceeds this limit, it will be automatically truncated with a notice appended.
npm install
npm run buildnpm testnpm run lintSee LICENSE for details.