A GitHub action to create or replace a pull request comment.
This action was created as a primitive for "report through comment" flow. Typical usecase could be to publish a comment with the link to the test coverage report on a pull request. Each new commit in the PR will lead to the previous comment being deleted, and a new one being append below.
- uses: brightnetwork/[email protected]
with:
id: frontend-coverage
body: |
${{ github.event.pull_request.head.sha }}: test coverage published:
https://my-site.com/${{ github.event.pull_request.head.sha }}/index.html
The id: frontend-coverage
here ensure the de-duplication. If a comment created by this action with the same id already exist, then it will be deleted.
- uses: brightnetwork/[email protected]
with:
id: backend-coverage
template-path: .github/templates/comment.md
template-var: step.XX.outputs.2
Templating is done with ejs. The full github action context is available in the templating context.
<%= context.payload.pull_request.head.sha %> **CI check: comment from template**
Step 2 output: <%= input %>
<details>
<summary>Hello, <%= context.payload.sender.login %>! gh action context:</summary>
```json
<%- JSON.stringify(context, undefined, 2) %>
```
</details>
- Create or Update Comment is similar, but focused on a different flow (ChatOps). This action comes with "battery included" regarding the "report through comment" flow: delete and create by default, templating included.
- Architecture is mainly coming from github typescript action
- There is no unit tests (for now), but an action is running on each PR that use this repo to comment the PR, and then analyze the results. This provides "end to end" testing.
dist
folder needs to be updated on each commit - this can be done by thenpm run package
command.