mirror of
https://github.com/peter-evans/create-or-update-comment.git
synced 2025-01-19 11:46:40 +08:00
Merge pull request #62 from DanielHabenicht/master
Add example for automatically updating a previously created comment
This commit is contained in:
commit
c966195fd8
34
README.md
34
README.md
@ -103,14 +103,34 @@ Some use cases might find the [find-comment](https://github.com/peter-evans/find
|
|||||||
This will search an issue or pull request for the first comment containing a specified string, and/or by a specified author.
|
This will search an issue or pull request for the first comment containing a specified string, and/or by a specified author.
|
||||||
See the repository for detailed usage.
|
See the repository for detailed usage.
|
||||||
|
|
||||||
|
In the following example, find-comment is used to determine a comment has already been created on a pull request. In this case, the comment will be updated instead of being created.
|
||||||
```yml
|
```yml
|
||||||
- name: Find Comment
|
- name: Find Comment
|
||||||
uses: peter-evans/find-comment@v1
|
uses: peter-evans/find-comment@v1
|
||||||
id: fc
|
id: fc
|
||||||
with:
|
with:
|
||||||
issue-number: 1
|
issue-number: ${{ github.event.pull_request.number }} #e.g. 1
|
||||||
comment-author: peter-evans
|
comment-author: 'github-actions[bot]'
|
||||||
body-includes: search string 1
|
body-includes: This comment was written by a bot!
|
||||||
|
|
||||||
|
- name: Create comment
|
||||||
|
if: ${{ steps.fc.outputs.comment-id == 0 }}
|
||||||
|
uses: peter-evans/create-or-update-comment@v1
|
||||||
|
with:
|
||||||
|
issue-number: ${{ github.event.pull_request.number }}
|
||||||
|
body: |
|
||||||
|
This comment was written by a bot!
|
||||||
|
reaction-type: "rocket"
|
||||||
|
|
||||||
|
- name: Update comment
|
||||||
|
if: ${{ steps.fc.outputs.comment-id != 0 }}
|
||||||
|
uses: peter-evans/create-or-update-comment@v1
|
||||||
|
with:
|
||||||
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
||||||
|
body: |
|
||||||
|
Update!
|
||||||
|
Comments can also be updated by us. :)
|
||||||
|
reaction-type: "rocket"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Setting the comment body from a file
|
### Setting the comment body from a file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user