fix: don't require bot ID match when header is present
The bot_id default (41898282 = github-actions[bot]) doesn't match
claude[bot] (209825114) when using OIDC auth. This caused the sticky
comment matching to always fail, creating new comments each run.
Header-based matching is authoritative — if a comment has our specific
<!-- bot: {id} --> header, that's sufficient for identification. Bot ID
check is now only used for legacy comments without headers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
600162b09b
commit
3128a645ab
@ -50,10 +50,6 @@ export async function createInitialComment(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const existingComment = comments.find((comment) => {
|
const existingComment = comments.find((comment) => {
|
||||||
// Must be from the correct bot user
|
|
||||||
const idMatch = comment.user?.id === Number(context.inputs.botId);
|
|
||||||
if (!idMatch) return false;
|
|
||||||
|
|
||||||
if (botIdentifier) {
|
if (botIdentifier) {
|
||||||
// Check for our hidden header (case-insensitive, whitespace-tolerant)
|
// Check for our hidden header (case-insensitive, whitespace-tolerant)
|
||||||
const headerPattern = new RegExp(
|
const headerPattern = new RegExp(
|
||||||
@ -67,12 +63,15 @@ export async function createInitialComment(
|
|||||||
comment.body || "",
|
comment.body || "",
|
||||||
);
|
);
|
||||||
|
|
||||||
// If comment has a header, ONLY match if it's ours
|
// Header match is authoritative — no bot ID check needed
|
||||||
if (hasAnyHeader) {
|
if (hasAnyHeader) {
|
||||||
return hasOurHeader;
|
return hasOurHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy comments (no header): match if it looks like a Claude comment
|
// Legacy comments (no header): require bot ID + Claude content
|
||||||
|
const idMatch = comment.user?.id === Number(context.inputs.botId);
|
||||||
|
if (!idMatch) return false;
|
||||||
|
|
||||||
const isClaudeComment =
|
const isClaudeComment =
|
||||||
comment.body?.includes("Claude Code is working") ||
|
comment.body?.includes("Claude Code is working") ||
|
||||||
comment.body?.includes("View job run");
|
comment.body?.includes("View job run");
|
||||||
@ -80,11 +79,12 @@ export async function createInitialComment(
|
|||||||
return isClaudeComment;
|
return isClaudeComment;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback when no botIdentifier: match any Claude-looking comment
|
// Fallback when no botIdentifier: match by bot user
|
||||||
|
const idMatch = comment.user?.id === Number(context.inputs.botId);
|
||||||
const botNameMatch =
|
const botNameMatch =
|
||||||
comment.user?.type === "Bot" &&
|
comment.user?.type === "Bot" &&
|
||||||
comment.user?.login.toLowerCase().includes("claude");
|
comment.user?.login.toLowerCase().includes("claude");
|
||||||
return botNameMatch;
|
return idMatch || botNameMatch;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (existingComment) {
|
if (existingComment) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user