Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/artyom/post-pr-comment
GitHub Action to post comment on a pull request
https://github.com/artyom/post-pr-comment
github-actions templating
Last synced: about 11 hours ago
JSON representation
GitHub Action to post comment on a pull request
- Host: GitHub
- URL: https://github.com/artyom/post-pr-comment
- Owner: artyom
- License: mit
- Created: 2021-07-28T14:49:11.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-16T12:16:35.000Z (7 months ago)
- Last Synced: 2024-10-28T20:55:10.754Z (17 days ago)
- Topics: github-actions, templating
- Language: Go
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Comment on a GitHub pull request
This GitHub actions adds a comment on a pull request, using provided template and variables to fill it.
## Inputs
* `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](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions) 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](https://pkg.go.dev/text/template), its documentation provides details on supported syntax.
* `variables-file` (**required**): path to the JSON file with the template variables mapping.## Outputs
* `comment-id`: integer ID of the comment created.
* `comment-url`: full URL pointing to the comment created.## Example usage
```yaml
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 example
Template file like this:
```text
Here's your list of {{.name}}:{{range .items -}}
* {{.}}
{{end}}
```And a variable mapping JSON file for this template:
```json
{
"name": "animals",
"items": [
"dog",
"cat"
]
}
```Produce such an output:
```text
Here's your list of animals:* dog
* cat
```You can experiment with rendering in the playground: