From d0c22e760c035b1caf83475c9b1d41eee7feffc2 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 27 Jun 2024 23:09:48 +0200 Subject: [PATCH] Always create new comments for release (#111) * Always create new comments for release * Update shared-release-branches.yml --- .github/workflows/shared-release-branches.yml | 45 ++++--------------- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/.github/workflows/shared-release-branches.yml b/.github/workflows/shared-release-branches.yml index f2873c6..e6f1e52 100644 --- a/.github/workflows/shared-release-branches.yml +++ b/.github/workflows/shared-release-branches.yml @@ -57,7 +57,7 @@ jobs: } // Function to create or update a comment for a pull request (PR) associated with a release - async function createOrUpdateCommentForPR(pr_id, release) { + async function createCommentForPR(pr_id, release) { // Parameters for fetching comments related to the PR const parameters = { owner: context.repo.owner, @@ -66,9 +66,6 @@ jobs: per_page: 100, } - // Initialize existingComment variable - let existingComment = null; - // Constructing the message to be posted or updated as a comment const messageId = ``; const message = ` @@ -76,37 +73,13 @@ jobs: These changes were released in [${release.name}](${release.html_url}). `; - // Iterating through all comments related to the PR - const allComments = github.paginate.iterator(github.rest.issues.listComments, parameters); - for await (comments of allComments) { - // Check if the message id is present in any of the comments - found = comments.data.find(({ body }) => { - return (body?.search(messageId) != -1) > -1; - }); - - if (found) { - break; // Exit the loop if the comment is found - } - } - - // If the comment is found, update it; otherwise, create a new comment - if (found) { - console.log(`Comment found`); - await github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: found.id, - body: message - }); - } else { - console.log(`Comment not found`); - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pr_id, - body: message - }); - } + // Сreate a new comment + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr_id, + body: message + }); } // Retrieving the ID of the current release @@ -198,6 +171,6 @@ jobs: // Iterating through unique pull request numbers and creating or updating comments for them for (id of pull_requests.filter(onlyUnique)) { - await createOrUpdateCommentForPR(id, currentRelease); + await createCommentForPR(id, currentRelease); }