mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-05-04 16:42:10 +00:00
fix: use the current user instead of the hardcoded user
This commit is contained in:
parent
2e4e3c25ba
commit
5b1f0528db
12
.github/scripts/load-cards.ts
vendored
12
.github/scripts/load-cards.ts
vendored
@ -351,15 +351,19 @@ async function postOrUpdatePRComment(
|
||||
prNumber: number,
|
||||
commentBody: string,
|
||||
): Promise<void> {
|
||||
// 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}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user