This GitHub actions adds a comment on a pull request, using provided template and variables to fill it.
-
github-token
(required): GitHub token to access API to post comment. Usually this is the${{ github.token }}
variable.If you limit the default permission scope for the token, make sure to grant
pull-requests: write
access. -
template-file
(required): path to the template file. Template is processed using Go text/template package, its documentation provides details on supported syntax. -
variables-file
(required): path to the JSON file with the template variables mapping.
comment-id
: integer ID of the comment created.comment-url
: full URL pointing to the comment created.
steps:
- uses: actions/checkout@v2
- uses: artyom/post-pr-comment@v1
with:
github-token: ${{ github.token }}
template-file: template.txt
variables-file: vars.json
Template file like this:
Here's your list of {{.name}}:
{{range .items -}}
* {{.}}
{{end}}
And a variable mapping JSON file for this template:
{
"name": "animals",
"items": [
"dog",
"cat"
]
}
Produce such an output:
Here's your list of animals:
* dog
* cat
You can experiment with rendering in the playground: https://play.golang.org/p/TOl7HrQHnVT