mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-05-05 00:52:08 +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,
|
prNumber: number,
|
||||||
commentBody: string,
|
commentBody: string,
|
||||||
): Promise<void> {
|
): 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({
|
const commentsResponse = await octokit.rest.issues.listComments({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
issue_number: prNumber,
|
issue_number: prNumber,
|
||||||
});
|
});
|
||||||
|
|
||||||
const botLogin = "github-actions[bot]";
|
// Look for existing comments from our authenticated bot user
|
||||||
const existingComment = commentsResponse.data.find(
|
const existingComment = commentsResponse.data.find(
|
||||||
(comment) => comment.user?.login === botLogin && comment.body?.includes("## 🃏"),
|
(comment) => comment.user?.login === authenticatedUser.login && comment.body?.includes("## 🃏"),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (existingComment) {
|
if (existingComment) {
|
||||||
@ -369,7 +373,7 @@ async function postOrUpdatePRComment(
|
|||||||
comment_id: existingComment.id,
|
comment_id: existingComment.id,
|
||||||
body: commentBody,
|
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 {
|
} else {
|
||||||
await octokit.rest.issues.createComment({
|
await octokit.rest.issues.createComment({
|
||||||
owner,
|
owner,
|
||||||
@ -377,7 +381,7 @@ async function postOrUpdatePRComment(
|
|||||||
issue_number: prNumber,
|
issue_number: prNumber,
|
||||||
body: commentBody,
|
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