A composite GitHub action that can be used to find a GitHub Issue or Pull Request comment by a specified value and then update the comment if found or create it if not found.
This is nothing more than a combination of the awesome work done by Peter Evans. I'm combining the find-comment and the create-or-update-comment because I found that I end up using those actions together a lot of the time.
This is a implementation of what is described in the docs for create-or-update-comment.
- name: Update PR with test results
uses: edumserrano/find-create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: '<!-- pr-test-results -->'
comment-author: 'github-actions[bot]'
body: | # can be a single value or you can compose text with multi-line values
<!-- pr-test-results -->
${{ steps.test-results.outputs.results }}
edit-mode: replace
Name | Description | Required | Default value |
---|---|---|---|
token |
GITHUB_TOKEN or a repo scoped PAT. | yes | github.token (job token) |
repository |
The full name of the repository containing the issue or pull request where to find, create or update the comment. | yes | github.repository (current repository) |
issue-number |
The number of the issue or pull request in which to find, create or update the comment. | yes | - |
body-includes |
A string to search for in the body of comments. | yes | - |
comment-author |
The GitHub user name of the comment author. | false | - |
body |
The comment body. | yes | - |
edit-mode |
The mode when updating a comment, replace or append. | yes | - |
reactions |
A comma separated list of reactions to add to the comment (+1, -1, laugh, confused, heart, hooray, rocket, eyes). | false | - |
- In your issue or pull request comment, you can include a piece of text that is a comment and therefore is not rendered by using the HTML tag comment syntax:
<!-- this is a comment -->
. Then you can use that HTML comment tag as an identifier for the comment you want to find and update.- The idea is that the HTML tag comment you choose will serve as unique identifier for the comment you want to find and update. This is a much better way to be sure that you will not get a false positive by searching for a non-comment piece of text.
For notes aimed at developers working on this repo or just trying to understand it go here.