From 5b1f0528db059289481f5134cbf5c6a7310503a3 Mon Sep 17 00:00:00 2001 From: Avior Date: Sun, 4 May 2025 00:15:03 +0200 Subject: [PATCH] fix: use the current user instead of the hardcoded user --- .github/scripts/load-cards.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/scripts/load-cards.ts b/.github/scripts/load-cards.ts index 604ec5e32..ff50125da 100644 --- a/.github/scripts/load-cards.ts +++ b/.github/scripts/load-cards.ts @@ -351,15 +351,19 @@ async function postOrUpdatePRComment( prNumber: number, commentBody: string, ): Promise { + // Get authenticated user info to identify our bot + const { data: authenticatedUser } = await octokit.rest.users.getAuthenticated(); + console.log(`Authenticated as user: ${authenticatedUser.login}`); + const commentsResponse = await octokit.rest.issues.listComments({ owner, repo, issue_number: prNumber, }); - const botLogin = "github-actions[bot]"; + // Look for existing comments from our authenticated bot user const existingComment = commentsResponse.data.find( - (comment) => comment.user?.login === botLogin && comment.body?.includes("## 🃏"), + (comment) => comment.user?.login === authenticatedUser.login && comment.body?.includes("## 🃏"), ); if (existingComment) { @@ -369,7 +373,7 @@ async function postOrUpdatePRComment( comment_id: existingComment.id, body: commentBody, }); - console.log(`Updated existing comment #${existingComment.id} on PR #${prNumber}`); + console.log(`Updated existing comment #${existingComment.id} on PR #${prNumber} as ${authenticatedUser.login}`); } else { await octokit.rest.issues.createComment({ owner, @@ -377,7 +381,7 @@ async function postOrUpdatePRComment( issue_number: prNumber, body: commentBody, }); - console.log(`Posted new comment to PR #${prNumber}`); + console.log(`Posted new comment to PR #${prNumber} as ${authenticatedUser.login}`); } }