From 910158d07e1e69e68222eab4062829129d3cc6af Mon Sep 17 00:00:00 2001 From: DanielHabenicht Date: Wed, 14 Oct 2020 15:08:11 +0200 Subject: [PATCH 1/4] Update README.md Add example for automatically updating a previously created comment. --- README.md | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index da0c58a..0630042 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ jobs: ``` Some use cases might find the [find-comment](https://github.com/peter-evans/find-comment) action useful. -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, e.g. allowing to update a previously created comment. See the repository for detailed usage. ```yml @@ -109,8 +109,35 @@ See the repository for detailed usage. id: fc with: issue-number: 1 - comment-author: peter-evans + body-includes: search string 1 + steps: + - name: Find Comment + uses: peter-evans/find-comment@v1 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} #e.g. 1 + # comment-author: peter-evans (does not work with "github-actions" author) + 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 From 08f8c2cea38ecc9512ea6110afb0ec9461c56a2f Mon Sep 17 00:00:00 2001 From: DanielHabenicht Date: Wed, 14 Oct 2020 15:12:44 +0200 Subject: [PATCH 2/4] Update README.md remove previous example --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index 0630042..9e54260 100644 --- a/README.md +++ b/README.md @@ -104,14 +104,6 @@ This will search an issue or pull request for the first comment containing a spe See the repository for detailed usage. ```yml - - name: Find Comment - uses: peter-evans/find-comment@v1 - id: fc - with: - issue-number: 1 - - body-includes: search string 1 - steps: - name: Find Comment uses: peter-evans/find-comment@v1 id: fc From 51c15391aeb277736a8f2508094afec3b9c8ae07 Mon Sep 17 00:00:00 2001 From: DanielHabenicht Date: Thu, 15 Oct 2020 07:54:13 +0200 Subject: [PATCH 3/4] Update README.md Co-authored-by: Peter Evans <18365890+peter-evans@users.noreply.github.com> --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e54260..843a23f 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,10 @@ jobs: ``` Some use cases might find the [find-comment](https://github.com/peter-evans/find-comment) action useful. -This will search an issue or pull request for the first comment containing a specified string, and/or by a specified author, e.g. allowing to update a previously created comment. +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. +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 - name: Find Comment uses: peter-evans/find-comment@v1 From 56603d7af0f8c1f411e1825997c3f56088304a66 Mon Sep 17 00:00:00 2001 From: DanielHabenicht Date: Thu, 15 Oct 2020 09:27:20 +0200 Subject: [PATCH 4/4] Update README.md Co-authored-by: Peter Evans <18365890+peter-evans@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 843a23f..3830589 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ In the following example, find-comment is used to determine a comment has alread id: fc with: issue-number: ${{ github.event.pull_request.number }} #e.g. 1 - # comment-author: peter-evans (does not work with "github-actions" author) + comment-author: 'github-actions[bot]' body-includes: This comment was written by a bot! - name: Create comment