Comment on a GitHub Issue using an optional Handlebars template or body string. No need to manually find an existing comment to update, just supply a custom comment ID and the Action will track the comment automatically.
Features:
name: 'Comment On Pull Request'
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
deploy:
name: 'Render'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: badsyntax/github-action-issue-comment@master
name: Comment on Pull Request With Template
if: github.event_name == 'pull_request'
with:
action: 'create-clean', # one of "create", "update", "delete", or "create-clean"
template: '.github/pr-comment-template.hbs'
id: example
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
template-inputs: |
{
"firstName": "Bob",
"lastName": "Marley"
}
- uses: badsyntax/github-action-issue-comment@master
name: Comment on Pull Request With Body
if: github.event_name == 'pull_request'
with:
action: 'create-clean'
id: example2
issue-number: ${{ github.event.pull_request.number }}
body: 'Test comment'
token: ${{ secrets.GITHUB_TOKEN }}
The comment ID must be unique across jobs and matrix runs, for example:
jobs:
example:
strategy:
matrix:
account: [aa-a, aa-b, aa-c, aa-d, aa-e, aa-f]
# ...
steps:
- uses: badsyntax/github-action-issue-comment@master
name: Template Comment
id: example-job-${{ matrix.account }}
# ...
Name | Description | Example |
---|---|---|
action |
Action, one of update , create , delete , or create-clean '. The update action will first create a comment if it doesn't exist, else update it. create-clean will first delete the existing comment, then create a new comment |
update |
template |
The path to the handlebars template file, if not using the body option (optional) |
./.github/pr-comment-template.hbs |
body |
The comment body, if not using the template option (optional) |
A comment body |
template-inputs |
A JSON object of key value pairs (required only if using the template option) (can include newlines) |
{"key":"value"} |
token |
GITHUB_TOKEN (issues: write, pull-requests: write) or a repo scoped PAT | ${{ secrets.GITHUB_TOKEN }} |
issue-number |
The GitHub issue number |
${{ github.event.pull_request.number }} or ${{ github.event.issue.number }}
|
See LICENSE.md.