Create and manage automatic comments in a Github PR
Low maintenance activity. Last release 21 months ago. Weaker on commit activity and recent releases.
pip install pr-commenterpr-commenter
Create and manage automatic comments in a Github PR
pr-commenter is CLI app to add a comment a Github PR based on content from stdin, files or environment variables.
You can create a new comment, hide a previous one of the same type or update the "current" one from a different process. This is done with a hidden metadata added to the comment so it could be detected in a subsequent run, and update or hide previous messages if needed.
Basic usage
Create a Github token with repo scope and export it as PR_COMMENTER_GITHUB_TOKEN environment variable
pr-commenter your/repo 12 comment.txt
Or from the standard input, using - as the file name
cat comment.txt | pr-commenter your/repo 12 -
This will simply create a new comment in the PR 12 with the content of comment.txt
But there is much more.
Advanced example
Suposse you have a template failed_tests.j2 like this
{% if not is_append %}## Failed tests{% endif %}
[suite {{ CI_SUITE_NAME }}]({{ CI_SUITE_URL }}):
```bash
{% for line in input_lines %}{{ line }}
{% endfor %}
Then your test-runner produces a file failures.txt with the list
of failed tests like this:
tests/test_client.py::test_client_simple
tests/test_client.py::test_client_complex
So we want to add a single comment to the PR with the failed tests for two different suites executions triggered by the same "commit".
In the post-build phase of both suites, you can run something like
pr-commenter your/repo $PR failures.txt -t failed_tests.j2 --build=$COMMIT