From 4a8ad278e9c521f7fee07c3c9ab19d96bb643ee4 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 2 Apr 2024 01:18:16 +0900 Subject: [PATCH] chore: added every build to the git comment --- .github/workflows/deploy.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4b23b36a..d19c492e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -85,18 +85,25 @@ jobs: // Find the comment to update or create a new one if not found let existingComment = comments.data.find(comment => comment.user.login === 'github-actions[bot]'); - let body = `| Preview Deployment | [${sha}](${{ env.CLAIMABLE_URL }}) |\n| ------------------ | -------- |\n`; - + let body = ''; + // If the comment exists, update its body if (existingComment) { - await github.rest.issues.updateComment({ - owner, - repo, - comment_id: existingComment.id, - body - }); + // Check if the SHA already exists in the comment body to avoid duplicates + if (!existingComment.body.includes(sha)) { + body = existingComment.body + `| [${sha}](${{ env.CLAIMABLE_URL }}) |\n`; + await github.rest.issues.updateComment({ + owner, + repo, + comment_id: existingComment.id, + body + }); + } } else { // Create a new comment if no existing comment is found + body = '| Preview Deployment |\n| ------------------ |\n'; + body += `| [${sha}](${{ env.CLAIMABLE_URL }}) |\n`; + await github.rest.issues.createComment({ owner, repo,