diff --git a/.github/workflows/brave.lock.yml b/.github/workflows/brave.lock.yml index fe7ad65d4e9..febfd0bfeb9 100644 --- a/.github/workflows/brave.lock.yml +++ b/.github/workflows/brave.lock.yml @@ -356,7 +356,7 @@ jobs: } let reactionEndpoint; let commentUpdateEndpoint; - let shouldEditComment = false; + let shouldCreateComment = false; const eventName = context.eventName; const owner = context.repo.owner; const repo = context.repo.repo; @@ -370,7 +370,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/comments`; - shouldEditComment = true; break; case "issue_comment": const commentId = context.payload?.comment?.id; @@ -380,7 +379,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "pull_request": const prNumber = context.payload?.pull_request?.number; @@ -390,7 +389,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/comments`; - shouldEditComment = true; break; case "pull_request_review_comment": const reviewCommentId = context.payload?.comment?.id; @@ -400,7 +398,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "discussion": const discussionNumber = context.payload?.discussion?.number; @@ -411,7 +409,6 @@ jobs: const discussion = await getDiscussionId(owner, repo, discussionNumber); reactionEndpoint = discussion.id; commentUpdateEndpoint = `discussion:${discussionNumber}`; - shouldEditComment = true; break; case "discussion_comment": const discussionCommentNumber = context.payload?.discussion?.number; @@ -427,7 +424,7 @@ jobs: } reactionEndpoint = commentNodeId; commentUpdateEndpoint = `discussion_comment:${discussionCommentNumber}:${discussionCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; default: core.setFailed(`Unsupported event type: ${eventName}`); @@ -440,20 +437,20 @@ jobs: } else { await addReaction(reactionEndpoint, reaction); } - if (shouldEditComment && commentUpdateEndpoint) { + if (shouldCreateComment && commentUpdateEndpoint) { core.info(`Comment endpoint: ${commentUpdateEndpoint}`); - await addOrEditCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); + await addCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); } else { if (!command && commentUpdateEndpoint) { - core.info("Skipping comment edit - only available for command workflows"); + core.info("Skipping comment creation - only available for command workflows"); } else { core.info(`Skipping comment for event type: ${eventName}`); } } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - core.error(`Failed to process reaction and comment edit: ${errorMessage}`); - core.setFailed(`Failed to process reaction and comment edit: ${errorMessage}`); + core.error(`Failed to process reaction and comment creation: ${errorMessage}`); + core.setFailed(`Failed to process reaction and comment creation: ${errorMessage}`); } } async function addReaction(endpoint, reaction) { @@ -536,7 +533,7 @@ jobs: } throw new Error(`Discussion comment node ID not found in event payload for comment ${commentId}`); } - async function addOrEditCommentWithWorkflowLink(endpoint, runUrl, eventName) { + async function addCommentWithWorkflowLink(endpoint, runUrl, eventName) { try { const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow"; if (eventName === "discussion") { @@ -646,7 +643,7 @@ jobs: } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.warning( - "Failed to add/edit comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage + "Failed to create comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage ); } } diff --git a/.github/workflows/changeset-generator.lock.yml b/.github/workflows/changeset-generator.lock.yml index 973e233aaaf..61a47836ba4 100644 --- a/.github/workflows/changeset-generator.lock.yml +++ b/.github/workflows/changeset-generator.lock.yml @@ -348,7 +348,7 @@ jobs: } let reactionEndpoint; let commentUpdateEndpoint; - let shouldEditComment = false; + let shouldCreateComment = false; const eventName = context.eventName; const owner = context.repo.owner; const repo = context.repo.repo; @@ -362,7 +362,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/comments`; - shouldEditComment = true; break; case "issue_comment": const commentId = context.payload?.comment?.id; @@ -372,7 +371,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "pull_request": const prNumber = context.payload?.pull_request?.number; @@ -382,7 +381,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/comments`; - shouldEditComment = true; break; case "pull_request_review_comment": const reviewCommentId = context.payload?.comment?.id; @@ -392,7 +390,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "discussion": const discussionNumber = context.payload?.discussion?.number; @@ -403,7 +401,6 @@ jobs: const discussion = await getDiscussionId(owner, repo, discussionNumber); reactionEndpoint = discussion.id; commentUpdateEndpoint = `discussion:${discussionNumber}`; - shouldEditComment = true; break; case "discussion_comment": const discussionCommentNumber = context.payload?.discussion?.number; @@ -419,7 +416,7 @@ jobs: } reactionEndpoint = commentNodeId; commentUpdateEndpoint = `discussion_comment:${discussionCommentNumber}:${discussionCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; default: core.setFailed(`Unsupported event type: ${eventName}`); @@ -432,20 +429,20 @@ jobs: } else { await addReaction(reactionEndpoint, reaction); } - if (shouldEditComment && commentUpdateEndpoint) { + if (shouldCreateComment && commentUpdateEndpoint) { core.info(`Comment endpoint: ${commentUpdateEndpoint}`); - await addOrEditCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); + await addCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); } else { if (!command && commentUpdateEndpoint) { - core.info("Skipping comment edit - only available for command workflows"); + core.info("Skipping comment creation - only available for command workflows"); } else { core.info(`Skipping comment for event type: ${eventName}`); } } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - core.error(`Failed to process reaction and comment edit: ${errorMessage}`); - core.setFailed(`Failed to process reaction and comment edit: ${errorMessage}`); + core.error(`Failed to process reaction and comment creation: ${errorMessage}`); + core.setFailed(`Failed to process reaction and comment creation: ${errorMessage}`); } } async function addReaction(endpoint, reaction) { @@ -528,7 +525,7 @@ jobs: } throw new Error(`Discussion comment node ID not found in event payload for comment ${commentId}`); } - async function addOrEditCommentWithWorkflowLink(endpoint, runUrl, eventName) { + async function addCommentWithWorkflowLink(endpoint, runUrl, eventName) { try { const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow"; if (eventName === "discussion") { @@ -638,7 +635,7 @@ jobs: } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.warning( - "Failed to add/edit comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage + "Failed to create comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage ); } } diff --git a/.github/workflows/dev.lock.yml b/.github/workflows/dev.lock.yml index ec00dee3eff..89e95ff60ba 100644 --- a/.github/workflows/dev.lock.yml +++ b/.github/workflows/dev.lock.yml @@ -268,7 +268,7 @@ jobs: } let reactionEndpoint; let commentUpdateEndpoint; - let shouldEditComment = false; + let shouldCreateComment = false; const eventName = context.eventName; const owner = context.repo.owner; const repo = context.repo.repo; @@ -282,7 +282,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/comments`; - shouldEditComment = true; break; case "issue_comment": const commentId = context.payload?.comment?.id; @@ -292,7 +291,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "pull_request": const prNumber = context.payload?.pull_request?.number; @@ -302,7 +301,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/comments`; - shouldEditComment = true; break; case "pull_request_review_comment": const reviewCommentId = context.payload?.comment?.id; @@ -312,7 +310,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "discussion": const discussionNumber = context.payload?.discussion?.number; @@ -323,7 +321,6 @@ jobs: const discussion = await getDiscussionId(owner, repo, discussionNumber); reactionEndpoint = discussion.id; commentUpdateEndpoint = `discussion:${discussionNumber}`; - shouldEditComment = true; break; case "discussion_comment": const discussionCommentNumber = context.payload?.discussion?.number; @@ -339,7 +336,7 @@ jobs: } reactionEndpoint = commentNodeId; commentUpdateEndpoint = `discussion_comment:${discussionCommentNumber}:${discussionCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; default: core.setFailed(`Unsupported event type: ${eventName}`); @@ -352,20 +349,20 @@ jobs: } else { await addReaction(reactionEndpoint, reaction); } - if (shouldEditComment && commentUpdateEndpoint) { + if (shouldCreateComment && commentUpdateEndpoint) { core.info(`Comment endpoint: ${commentUpdateEndpoint}`); - await addOrEditCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); + await addCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); } else { if (!command && commentUpdateEndpoint) { - core.info("Skipping comment edit - only available for command workflows"); + core.info("Skipping comment creation - only available for command workflows"); } else { core.info(`Skipping comment for event type: ${eventName}`); } } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - core.error(`Failed to process reaction and comment edit: ${errorMessage}`); - core.setFailed(`Failed to process reaction and comment edit: ${errorMessage}`); + core.error(`Failed to process reaction and comment creation: ${errorMessage}`); + core.setFailed(`Failed to process reaction and comment creation: ${errorMessage}`); } } async function addReaction(endpoint, reaction) { @@ -448,7 +445,7 @@ jobs: } throw new Error(`Discussion comment node ID not found in event payload for comment ${commentId}`); } - async function addOrEditCommentWithWorkflowLink(endpoint, runUrl, eventName) { + async function addCommentWithWorkflowLink(endpoint, runUrl, eventName) { try { const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow"; if (eventName === "discussion") { @@ -558,7 +555,7 @@ jobs: } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.warning( - "Failed to add/edit comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage + "Failed to create comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage ); } } diff --git a/.github/workflows/issue-classifier.lock.yml b/.github/workflows/issue-classifier.lock.yml index aecbb1d663f..79003acb4f2 100644 --- a/.github/workflows/issue-classifier.lock.yml +++ b/.github/workflows/issue-classifier.lock.yml @@ -345,7 +345,7 @@ jobs: } let reactionEndpoint; let commentUpdateEndpoint; - let shouldEditComment = false; + let shouldCreateComment = false; const eventName = context.eventName; const owner = context.repo.owner; const repo = context.repo.repo; @@ -359,7 +359,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/comments`; - shouldEditComment = true; break; case "issue_comment": const commentId = context.payload?.comment?.id; @@ -369,7 +368,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "pull_request": const prNumber = context.payload?.pull_request?.number; @@ -379,7 +378,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/comments`; - shouldEditComment = true; break; case "pull_request_review_comment": const reviewCommentId = context.payload?.comment?.id; @@ -389,7 +387,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "discussion": const discussionNumber = context.payload?.discussion?.number; @@ -400,7 +398,6 @@ jobs: const discussion = await getDiscussionId(owner, repo, discussionNumber); reactionEndpoint = discussion.id; commentUpdateEndpoint = `discussion:${discussionNumber}`; - shouldEditComment = true; break; case "discussion_comment": const discussionCommentNumber = context.payload?.discussion?.number; @@ -416,7 +413,7 @@ jobs: } reactionEndpoint = commentNodeId; commentUpdateEndpoint = `discussion_comment:${discussionCommentNumber}:${discussionCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; default: core.setFailed(`Unsupported event type: ${eventName}`); @@ -429,20 +426,20 @@ jobs: } else { await addReaction(reactionEndpoint, reaction); } - if (shouldEditComment && commentUpdateEndpoint) { + if (shouldCreateComment && commentUpdateEndpoint) { core.info(`Comment endpoint: ${commentUpdateEndpoint}`); - await addOrEditCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); + await addCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); } else { if (!command && commentUpdateEndpoint) { - core.info("Skipping comment edit - only available for command workflows"); + core.info("Skipping comment creation - only available for command workflows"); } else { core.info(`Skipping comment for event type: ${eventName}`); } } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - core.error(`Failed to process reaction and comment edit: ${errorMessage}`); - core.setFailed(`Failed to process reaction and comment edit: ${errorMessage}`); + core.error(`Failed to process reaction and comment creation: ${errorMessage}`); + core.setFailed(`Failed to process reaction and comment creation: ${errorMessage}`); } } async function addReaction(endpoint, reaction) { @@ -525,7 +522,7 @@ jobs: } throw new Error(`Discussion comment node ID not found in event payload for comment ${commentId}`); } - async function addOrEditCommentWithWorkflowLink(endpoint, runUrl, eventName) { + async function addCommentWithWorkflowLink(endpoint, runUrl, eventName) { try { const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow"; if (eventName === "discussion") { @@ -635,7 +632,7 @@ jobs: } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.warning( - "Failed to add/edit comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage + "Failed to create comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage ); } } diff --git a/.github/workflows/pdf-summary.lock.yml b/.github/workflows/pdf-summary.lock.yml index 5e51b548e1f..4873a56fcd1 100644 --- a/.github/workflows/pdf-summary.lock.yml +++ b/.github/workflows/pdf-summary.lock.yml @@ -377,7 +377,7 @@ jobs: } let reactionEndpoint; let commentUpdateEndpoint; - let shouldEditComment = false; + let shouldCreateComment = false; const eventName = context.eventName; const owner = context.repo.owner; const repo = context.repo.repo; @@ -391,7 +391,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/comments`; - shouldEditComment = true; break; case "issue_comment": const commentId = context.payload?.comment?.id; @@ -401,7 +400,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "pull_request": const prNumber = context.payload?.pull_request?.number; @@ -411,7 +410,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/comments`; - shouldEditComment = true; break; case "pull_request_review_comment": const reviewCommentId = context.payload?.comment?.id; @@ -421,7 +419,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "discussion": const discussionNumber = context.payload?.discussion?.number; @@ -432,7 +430,6 @@ jobs: const discussion = await getDiscussionId(owner, repo, discussionNumber); reactionEndpoint = discussion.id; commentUpdateEndpoint = `discussion:${discussionNumber}`; - shouldEditComment = true; break; case "discussion_comment": const discussionCommentNumber = context.payload?.discussion?.number; @@ -448,7 +445,7 @@ jobs: } reactionEndpoint = commentNodeId; commentUpdateEndpoint = `discussion_comment:${discussionCommentNumber}:${discussionCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; default: core.setFailed(`Unsupported event type: ${eventName}`); @@ -461,20 +458,20 @@ jobs: } else { await addReaction(reactionEndpoint, reaction); } - if (shouldEditComment && commentUpdateEndpoint) { + if (shouldCreateComment && commentUpdateEndpoint) { core.info(`Comment endpoint: ${commentUpdateEndpoint}`); - await addOrEditCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); + await addCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); } else { if (!command && commentUpdateEndpoint) { - core.info("Skipping comment edit - only available for command workflows"); + core.info("Skipping comment creation - only available for command workflows"); } else { core.info(`Skipping comment for event type: ${eventName}`); } } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - core.error(`Failed to process reaction and comment edit: ${errorMessage}`); - core.setFailed(`Failed to process reaction and comment edit: ${errorMessage}`); + core.error(`Failed to process reaction and comment creation: ${errorMessage}`); + core.setFailed(`Failed to process reaction and comment creation: ${errorMessage}`); } } async function addReaction(endpoint, reaction) { @@ -557,7 +554,7 @@ jobs: } throw new Error(`Discussion comment node ID not found in event payload for comment ${commentId}`); } - async function addOrEditCommentWithWorkflowLink(endpoint, runUrl, eventName) { + async function addCommentWithWorkflowLink(endpoint, runUrl, eventName) { try { const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow"; if (eventName === "discussion") { @@ -667,7 +664,7 @@ jobs: } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.warning( - "Failed to add/edit comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage + "Failed to create comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage ); } } diff --git a/.github/workflows/plan.lock.yml b/.github/workflows/plan.lock.yml index 91b66b56ff3..e6bdc76004b 100644 --- a/.github/workflows/plan.lock.yml +++ b/.github/workflows/plan.lock.yml @@ -347,7 +347,7 @@ jobs: } let reactionEndpoint; let commentUpdateEndpoint; - let shouldEditComment = false; + let shouldCreateComment = false; const eventName = context.eventName; const owner = context.repo.owner; const repo = context.repo.repo; @@ -361,7 +361,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/comments`; - shouldEditComment = true; break; case "issue_comment": const commentId = context.payload?.comment?.id; @@ -371,7 +370,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "pull_request": const prNumber = context.payload?.pull_request?.number; @@ -381,7 +380,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/comments`; - shouldEditComment = true; break; case "pull_request_review_comment": const reviewCommentId = context.payload?.comment?.id; @@ -391,7 +389,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "discussion": const discussionNumber = context.payload?.discussion?.number; @@ -402,7 +400,6 @@ jobs: const discussion = await getDiscussionId(owner, repo, discussionNumber); reactionEndpoint = discussion.id; commentUpdateEndpoint = `discussion:${discussionNumber}`; - shouldEditComment = true; break; case "discussion_comment": const discussionCommentNumber = context.payload?.discussion?.number; @@ -418,7 +415,7 @@ jobs: } reactionEndpoint = commentNodeId; commentUpdateEndpoint = `discussion_comment:${discussionCommentNumber}:${discussionCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; default: core.setFailed(`Unsupported event type: ${eventName}`); @@ -431,20 +428,20 @@ jobs: } else { await addReaction(reactionEndpoint, reaction); } - if (shouldEditComment && commentUpdateEndpoint) { + if (shouldCreateComment && commentUpdateEndpoint) { core.info(`Comment endpoint: ${commentUpdateEndpoint}`); - await addOrEditCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); + await addCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); } else { if (!command && commentUpdateEndpoint) { - core.info("Skipping comment edit - only available for command workflows"); + core.info("Skipping comment creation - only available for command workflows"); } else { core.info(`Skipping comment for event type: ${eventName}`); } } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - core.error(`Failed to process reaction and comment edit: ${errorMessage}`); - core.setFailed(`Failed to process reaction and comment edit: ${errorMessage}`); + core.error(`Failed to process reaction and comment creation: ${errorMessage}`); + core.setFailed(`Failed to process reaction and comment creation: ${errorMessage}`); } } async function addReaction(endpoint, reaction) { @@ -527,7 +524,7 @@ jobs: } throw new Error(`Discussion comment node ID not found in event payload for comment ${commentId}`); } - async function addOrEditCommentWithWorkflowLink(endpoint, runUrl, eventName) { + async function addCommentWithWorkflowLink(endpoint, runUrl, eventName) { try { const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow"; if (eventName === "discussion") { @@ -637,7 +634,7 @@ jobs: } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.warning( - "Failed to add/edit comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage + "Failed to create comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage ); } } diff --git a/.github/workflows/poem-bot.lock.yml b/.github/workflows/poem-bot.lock.yml index cfba46ec886..80947f047e9 100644 --- a/.github/workflows/poem-bot.lock.yml +++ b/.github/workflows/poem-bot.lock.yml @@ -388,7 +388,7 @@ jobs: } let reactionEndpoint; let commentUpdateEndpoint; - let shouldEditComment = false; + let shouldCreateComment = false; const eventName = context.eventName; const owner = context.repo.owner; const repo = context.repo.repo; @@ -402,7 +402,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/comments`; - shouldEditComment = true; break; case "issue_comment": const commentId = context.payload?.comment?.id; @@ -412,7 +411,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "pull_request": const prNumber = context.payload?.pull_request?.number; @@ -422,7 +421,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/comments`; - shouldEditComment = true; break; case "pull_request_review_comment": const reviewCommentId = context.payload?.comment?.id; @@ -432,7 +430,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "discussion": const discussionNumber = context.payload?.discussion?.number; @@ -443,7 +441,6 @@ jobs: const discussion = await getDiscussionId(owner, repo, discussionNumber); reactionEndpoint = discussion.id; commentUpdateEndpoint = `discussion:${discussionNumber}`; - shouldEditComment = true; break; case "discussion_comment": const discussionCommentNumber = context.payload?.discussion?.number; @@ -459,7 +456,7 @@ jobs: } reactionEndpoint = commentNodeId; commentUpdateEndpoint = `discussion_comment:${discussionCommentNumber}:${discussionCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; default: core.setFailed(`Unsupported event type: ${eventName}`); @@ -472,20 +469,20 @@ jobs: } else { await addReaction(reactionEndpoint, reaction); } - if (shouldEditComment && commentUpdateEndpoint) { + if (shouldCreateComment && commentUpdateEndpoint) { core.info(`Comment endpoint: ${commentUpdateEndpoint}`); - await addOrEditCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); + await addCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); } else { if (!command && commentUpdateEndpoint) { - core.info("Skipping comment edit - only available for command workflows"); + core.info("Skipping comment creation - only available for command workflows"); } else { core.info(`Skipping comment for event type: ${eventName}`); } } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - core.error(`Failed to process reaction and comment edit: ${errorMessage}`); - core.setFailed(`Failed to process reaction and comment edit: ${errorMessage}`); + core.error(`Failed to process reaction and comment creation: ${errorMessage}`); + core.setFailed(`Failed to process reaction and comment creation: ${errorMessage}`); } } async function addReaction(endpoint, reaction) { @@ -568,7 +565,7 @@ jobs: } throw new Error(`Discussion comment node ID not found in event payload for comment ${commentId}`); } - async function addOrEditCommentWithWorkflowLink(endpoint, runUrl, eventName) { + async function addCommentWithWorkflowLink(endpoint, runUrl, eventName) { try { const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow"; if (eventName === "discussion") { @@ -678,7 +675,7 @@ jobs: } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.warning( - "Failed to add/edit comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage + "Failed to create comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage ); } } diff --git a/.github/workflows/q.lock.yml b/.github/workflows/q.lock.yml index f80c3c03cac..8396a721f24 100644 --- a/.github/workflows/q.lock.yml +++ b/.github/workflows/q.lock.yml @@ -399,7 +399,7 @@ jobs: } let reactionEndpoint; let commentUpdateEndpoint; - let shouldEditComment = false; + let shouldCreateComment = false; const eventName = context.eventName; const owner = context.repo.owner; const repo = context.repo.repo; @@ -413,7 +413,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/comments`; - shouldEditComment = true; break; case "issue_comment": const commentId = context.payload?.comment?.id; @@ -423,7 +422,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "pull_request": const prNumber = context.payload?.pull_request?.number; @@ -433,7 +432,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/comments`; - shouldEditComment = true; break; case "pull_request_review_comment": const reviewCommentId = context.payload?.comment?.id; @@ -443,7 +441,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "discussion": const discussionNumber = context.payload?.discussion?.number; @@ -454,7 +452,6 @@ jobs: const discussion = await getDiscussionId(owner, repo, discussionNumber); reactionEndpoint = discussion.id; commentUpdateEndpoint = `discussion:${discussionNumber}`; - shouldEditComment = true; break; case "discussion_comment": const discussionCommentNumber = context.payload?.discussion?.number; @@ -470,7 +467,7 @@ jobs: } reactionEndpoint = commentNodeId; commentUpdateEndpoint = `discussion_comment:${discussionCommentNumber}:${discussionCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; default: core.setFailed(`Unsupported event type: ${eventName}`); @@ -483,20 +480,20 @@ jobs: } else { await addReaction(reactionEndpoint, reaction); } - if (shouldEditComment && commentUpdateEndpoint) { + if (shouldCreateComment && commentUpdateEndpoint) { core.info(`Comment endpoint: ${commentUpdateEndpoint}`); - await addOrEditCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); + await addCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); } else { if (!command && commentUpdateEndpoint) { - core.info("Skipping comment edit - only available for command workflows"); + core.info("Skipping comment creation - only available for command workflows"); } else { core.info(`Skipping comment for event type: ${eventName}`); } } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - core.error(`Failed to process reaction and comment edit: ${errorMessage}`); - core.setFailed(`Failed to process reaction and comment edit: ${errorMessage}`); + core.error(`Failed to process reaction and comment creation: ${errorMessage}`); + core.setFailed(`Failed to process reaction and comment creation: ${errorMessage}`); } } async function addReaction(endpoint, reaction) { @@ -579,7 +576,7 @@ jobs: } throw new Error(`Discussion comment node ID not found in event payload for comment ${commentId}`); } - async function addOrEditCommentWithWorkflowLink(endpoint, runUrl, eventName) { + async function addCommentWithWorkflowLink(endpoint, runUrl, eventName) { try { const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow"; if (eventName === "discussion") { @@ -689,7 +686,7 @@ jobs: } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.warning( - "Failed to add/edit comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage + "Failed to create comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage ); } } diff --git a/.github/workflows/scout.lock.yml b/.github/workflows/scout.lock.yml index dd7803feb7b..7f403e768df 100644 --- a/.github/workflows/scout.lock.yml +++ b/.github/workflows/scout.lock.yml @@ -411,7 +411,7 @@ jobs: } let reactionEndpoint; let commentUpdateEndpoint; - let shouldEditComment = false; + let shouldCreateComment = false; const eventName = context.eventName; const owner = context.repo.owner; const repo = context.repo.repo; @@ -425,7 +425,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/comments`; - shouldEditComment = true; break; case "issue_comment": const commentId = context.payload?.comment?.id; @@ -435,7 +434,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "pull_request": const prNumber = context.payload?.pull_request?.number; @@ -445,7 +444,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/comments`; - shouldEditComment = true; break; case "pull_request_review_comment": const reviewCommentId = context.payload?.comment?.id; @@ -455,7 +453,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "discussion": const discussionNumber = context.payload?.discussion?.number; @@ -466,7 +464,6 @@ jobs: const discussion = await getDiscussionId(owner, repo, discussionNumber); reactionEndpoint = discussion.id; commentUpdateEndpoint = `discussion:${discussionNumber}`; - shouldEditComment = true; break; case "discussion_comment": const discussionCommentNumber = context.payload?.discussion?.number; @@ -482,7 +479,7 @@ jobs: } reactionEndpoint = commentNodeId; commentUpdateEndpoint = `discussion_comment:${discussionCommentNumber}:${discussionCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; default: core.setFailed(`Unsupported event type: ${eventName}`); @@ -495,20 +492,20 @@ jobs: } else { await addReaction(reactionEndpoint, reaction); } - if (shouldEditComment && commentUpdateEndpoint) { + if (shouldCreateComment && commentUpdateEndpoint) { core.info(`Comment endpoint: ${commentUpdateEndpoint}`); - await addOrEditCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); + await addCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); } else { if (!command && commentUpdateEndpoint) { - core.info("Skipping comment edit - only available for command workflows"); + core.info("Skipping comment creation - only available for command workflows"); } else { core.info(`Skipping comment for event type: ${eventName}`); } } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - core.error(`Failed to process reaction and comment edit: ${errorMessage}`); - core.setFailed(`Failed to process reaction and comment edit: ${errorMessage}`); + core.error(`Failed to process reaction and comment creation: ${errorMessage}`); + core.setFailed(`Failed to process reaction and comment creation: ${errorMessage}`); } } async function addReaction(endpoint, reaction) { @@ -591,7 +588,7 @@ jobs: } throw new Error(`Discussion comment node ID not found in event payload for comment ${commentId}`); } - async function addOrEditCommentWithWorkflowLink(endpoint, runUrl, eventName) { + async function addCommentWithWorkflowLink(endpoint, runUrl, eventName) { try { const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow"; if (eventName === "discussion") { @@ -701,7 +698,7 @@ jobs: } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.warning( - "Failed to add/edit comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage + "Failed to create comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage ); } } diff --git a/.github/workflows/tidy.lock.yml b/.github/workflows/tidy.lock.yml index 84fb4aff849..d3889cd61d2 100644 --- a/.github/workflows/tidy.lock.yml +++ b/.github/workflows/tidy.lock.yml @@ -198,7 +198,7 @@ jobs: } let reactionEndpoint; let commentUpdateEndpoint; - let shouldEditComment = false; + let shouldCreateComment = false; const eventName = context.eventName; const owner = context.repo.owner; const repo = context.repo.repo; @@ -212,7 +212,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/comments`; - shouldEditComment = true; break; case "issue_comment": const commentId = context.payload?.comment?.id; @@ -222,7 +221,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "pull_request": const prNumber = context.payload?.pull_request?.number; @@ -232,7 +231,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/comments`; - shouldEditComment = true; break; case "pull_request_review_comment": const reviewCommentId = context.payload?.comment?.id; @@ -242,7 +240,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "discussion": const discussionNumber = context.payload?.discussion?.number; @@ -253,7 +251,6 @@ jobs: const discussion = await getDiscussionId(owner, repo, discussionNumber); reactionEndpoint = discussion.id; commentUpdateEndpoint = `discussion:${discussionNumber}`; - shouldEditComment = true; break; case "discussion_comment": const discussionCommentNumber = context.payload?.discussion?.number; @@ -269,7 +266,7 @@ jobs: } reactionEndpoint = commentNodeId; commentUpdateEndpoint = `discussion_comment:${discussionCommentNumber}:${discussionCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; default: core.setFailed(`Unsupported event type: ${eventName}`); @@ -282,20 +279,20 @@ jobs: } else { await addReaction(reactionEndpoint, reaction); } - if (shouldEditComment && commentUpdateEndpoint) { + if (shouldCreateComment && commentUpdateEndpoint) { core.info(`Comment endpoint: ${commentUpdateEndpoint}`); - await addOrEditCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); + await addCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); } else { if (!command && commentUpdateEndpoint) { - core.info("Skipping comment edit - only available for command workflows"); + core.info("Skipping comment creation - only available for command workflows"); } else { core.info(`Skipping comment for event type: ${eventName}`); } } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - core.error(`Failed to process reaction and comment edit: ${errorMessage}`); - core.setFailed(`Failed to process reaction and comment edit: ${errorMessage}`); + core.error(`Failed to process reaction and comment creation: ${errorMessage}`); + core.setFailed(`Failed to process reaction and comment creation: ${errorMessage}`); } } async function addReaction(endpoint, reaction) { @@ -378,7 +375,7 @@ jobs: } throw new Error(`Discussion comment node ID not found in event payload for comment ${commentId}`); } - async function addOrEditCommentWithWorkflowLink(endpoint, runUrl, eventName) { + async function addCommentWithWorkflowLink(endpoint, runUrl, eventName) { try { const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow"; if (eventName === "discussion") { @@ -488,7 +485,7 @@ jobs: } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.warning( - "Failed to add/edit comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage + "Failed to create comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage ); } } diff --git a/.github/workflows/unbloat-docs.lock.yml b/.github/workflows/unbloat-docs.lock.yml index 5d9430ff3ce..29fc80f22f6 100644 --- a/.github/workflows/unbloat-docs.lock.yml +++ b/.github/workflows/unbloat-docs.lock.yml @@ -202,7 +202,7 @@ jobs: } let reactionEndpoint; let commentUpdateEndpoint; - let shouldEditComment = false; + let shouldCreateComment = false; const eventName = context.eventName; const owner = context.repo.owner; const repo = context.repo.repo; @@ -216,7 +216,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/comments`; - shouldEditComment = true; break; case "issue_comment": const commentId = context.payload?.comment?.id; @@ -226,7 +225,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "pull_request": const prNumber = context.payload?.pull_request?.number; @@ -236,7 +235,6 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/comments`; - shouldEditComment = true; break; case "pull_request_review_comment": const reviewCommentId = context.payload?.comment?.id; @@ -246,7 +244,7 @@ jobs: } reactionEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; case "discussion": const discussionNumber = context.payload?.discussion?.number; @@ -257,7 +255,6 @@ jobs: const discussion = await getDiscussionId(owner, repo, discussionNumber); reactionEndpoint = discussion.id; commentUpdateEndpoint = `discussion:${discussionNumber}`; - shouldEditComment = true; break; case "discussion_comment": const discussionCommentNumber = context.payload?.discussion?.number; @@ -273,7 +270,7 @@ jobs: } reactionEndpoint = commentNodeId; commentUpdateEndpoint = `discussion_comment:${discussionCommentNumber}:${discussionCommentId}`; - shouldEditComment = command ? true : false; + shouldCreateComment = command ? true : false; break; default: core.setFailed(`Unsupported event type: ${eventName}`); @@ -286,20 +283,20 @@ jobs: } else { await addReaction(reactionEndpoint, reaction); } - if (shouldEditComment && commentUpdateEndpoint) { + if (shouldCreateComment && commentUpdateEndpoint) { core.info(`Comment endpoint: ${commentUpdateEndpoint}`); - await addOrEditCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); + await addCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); } else { if (!command && commentUpdateEndpoint) { - core.info("Skipping comment edit - only available for command workflows"); + core.info("Skipping comment creation - only available for command workflows"); } else { core.info(`Skipping comment for event type: ${eventName}`); } } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - core.error(`Failed to process reaction and comment edit: ${errorMessage}`); - core.setFailed(`Failed to process reaction and comment edit: ${errorMessage}`); + core.error(`Failed to process reaction and comment creation: ${errorMessage}`); + core.setFailed(`Failed to process reaction and comment creation: ${errorMessage}`); } } async function addReaction(endpoint, reaction) { @@ -382,7 +379,7 @@ jobs: } throw new Error(`Discussion comment node ID not found in event payload for comment ${commentId}`); } - async function addOrEditCommentWithWorkflowLink(endpoint, runUrl, eventName) { + async function addCommentWithWorkflowLink(endpoint, runUrl, eventName) { try { const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow"; if (eventName === "discussion") { @@ -492,7 +489,7 @@ jobs: } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.warning( - "Failed to add/edit comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage + "Failed to create comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage ); } } diff --git a/pkg/workflow/js/add_reaction_and_edit_comment.cjs b/pkg/workflow/js/add_reaction_and_edit_comment.cjs index 0fd124df012..d696aa55215 100644 --- a/pkg/workflow/js/add_reaction_and_edit_comment.cjs +++ b/pkg/workflow/js/add_reaction_and_edit_comment.cjs @@ -23,7 +23,7 @@ async function main() { // Determine the API endpoint based on the event type let reactionEndpoint; let commentUpdateEndpoint; - let shouldEditComment = false; + let shouldCreateComment = false; const eventName = context.eventName; const owner = context.repo.owner; const repo = context.repo.repo; @@ -38,20 +38,24 @@ async function main() { } reactionEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${issueNumber}/comments`; - // Create a comment for issue events - shouldEditComment = true; break; case "issue_comment": const commentId = context.payload?.comment?.id; + const issueNumberForComment = context.payload?.issue?.number; if (!commentId) { core.setFailed("Comment ID not found in event payload"); return; } + if (!issueNumberForComment) { + core.setFailed("Issue number not found in event payload"); + return; + } reactionEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`; - commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}`; - // Only edit comments for command workflows - shouldEditComment = command ? true : false; + // Create new comment on the issue itself, not on the comment + commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${issueNumberForComment}/comments`; + // Only create comments for command workflows + shouldCreateComment = command ? true : false; break; case "pull_request": @@ -63,20 +67,24 @@ async function main() { // PRs are "issues" for the reactions endpoint reactionEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${prNumber}/comments`; - // Create a comment for pull request events - shouldEditComment = true; break; case "pull_request_review_comment": const reviewCommentId = context.payload?.comment?.id; + const prNumberForReviewComment = context.payload?.pull_request?.number; if (!reviewCommentId) { core.setFailed("Review comment ID not found in event payload"); return; } + if (!prNumberForReviewComment) { + core.setFailed("Pull request number not found in event payload"); + return; + } reactionEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}/reactions`; - commentUpdateEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}`; - // Only edit comments for command workflows - shouldEditComment = command ? true : false; + // Create new comment on the PR itself (using issues endpoint since PRs are issues) + commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/${prNumberForReviewComment}/comments`; + // Only create comments for command workflows + shouldCreateComment = command ? true : false; break; case "discussion": @@ -89,8 +97,6 @@ async function main() { const discussion = await getDiscussionId(owner, repo, discussionNumber); reactionEndpoint = discussion.id; // Store node ID for GraphQL commentUpdateEndpoint = `discussion:${discussionNumber}`; // Special format to indicate discussion - // Create a comment for discussion events - shouldEditComment = true; break; case "discussion_comment": @@ -108,8 +114,8 @@ async function main() { } reactionEndpoint = commentNodeId; // Store node ID for GraphQL commentUpdateEndpoint = `discussion_comment:${discussionCommentNumber}:${discussionCommentId}`; // Special format - // Only edit comments for command workflows - shouldEditComment = command ? true : false; + // Only create comments for command workflows + shouldCreateComment = command ? true : false; break; default: @@ -128,21 +134,21 @@ async function main() { await addReaction(reactionEndpoint, reaction); } - // Then add or edit comment if applicable - if (shouldEditComment && commentUpdateEndpoint) { + // Then add comment if applicable + if (shouldCreateComment && commentUpdateEndpoint) { core.info(`Comment endpoint: ${commentUpdateEndpoint}`); - await addOrEditCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); + await addCommentWithWorkflowLink(commentUpdateEndpoint, runUrl, eventName); } else { if (!command && commentUpdateEndpoint) { - core.info("Skipping comment edit - only available for command workflows"); + core.info("Skipping comment creation - only available for command workflows"); } else { core.info(`Skipping comment for event type: ${eventName}`); } } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - core.error(`Failed to process reaction and comment edit: ${errorMessage}`); - core.setFailed(`Failed to process reaction and comment edit: ${errorMessage}`); + core.error(`Failed to process reaction and comment creation: ${errorMessage}`); + core.setFailed(`Failed to process reaction and comment creation: ${errorMessage}`); } } @@ -273,12 +279,12 @@ async function getDiscussionCommentId(owner, repo, discussionNumber, commentId) } /** - * Add or edit a comment to add a workflow run link - * @param {string} endpoint - The GitHub API endpoint to update or create the comment (or special format for discussions) + * Add a comment with a workflow run link + * @param {string} endpoint - The GitHub API endpoint to create the comment (or special format for discussions) * @param {string} runUrl - The URL of the workflow run - * @param {string} eventName - The event type (to determine if we create or edit) + * @param {string} eventName - The event type (to determine the comment text) */ -async function addOrEditCommentWithWorkflowLink(endpoint, runUrl, eventName) { +async function addCommentWithWorkflowLink(endpoint, runUrl, eventName) { try { // Get workflow name from environment variable const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow"; @@ -406,10 +412,10 @@ async function addOrEditCommentWithWorkflowLink(endpoint, runUrl, eventName) { core.setOutput("comment-url", createResponse.data.html_url); core.setOutput("comment-repo", `${context.repo.owner}/${context.repo.repo}`); } catch (error) { - // Don't fail the entire job if comment editing/creation fails - just log it + // Don't fail the entire job if comment creation fails - just log it const errorMessage = error instanceof Error ? error.message : String(error); core.warning( - "Failed to add/edit comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage + "Failed to create comment with workflow link (This is not critical - the reaction was still added successfully): " + errorMessage ); } } diff --git a/pkg/workflow/js/add_reaction_and_edit_comment.test.cjs b/pkg/workflow/js/add_reaction_and_edit_comment.test.cjs index 50d19f0ef96..0bf03f02671 100644 --- a/pkg/workflow/js/add_reaction_and_edit_comment.test.cjs +++ b/pkg/workflow/js/add_reaction_and_edit_comment.test.cjs @@ -139,8 +139,9 @@ describe("add_reaction_and_edit_comment.cjs", () => { }); describe("Pull request reactions", () => { - it("should add reaction to pull request successfully", async () => { + it("should add reaction to pull request successfully (no comment)", async () => { process.env.GITHUB_AW_REACTION = "heart"; + // NO GITHUB_AW_COMMAND set - this is NOT a command workflow global.context.eventName = "pull_request"; global.context.payload = { pull_request: { number: 456 }, @@ -162,7 +163,11 @@ describe("add_reaction_and_edit_comment.cjs", () => { }) ); + // Verify only 1 call was made (reaction, no comment) + expect(mockGithub.request).toHaveBeenCalledTimes(1); + expect(mockCore.setOutput).toHaveBeenCalledWith("reaction-id", "789"); + expect(mockCore.setOutput).not.toHaveBeenCalledWith("comment-id", expect.anything()); }); }); @@ -331,40 +336,38 @@ describe("add_reaction_and_edit_comment.cjs", () => { }); describe("Comment creation (always creates new comments)", () => { - it("should create new comment for issue event", async () => { + it("should NOT create comment for issue event (non-command workflow)", async () => { process.env.GITHUB_AW_REACTION = "eyes"; process.env.GITHUB_AW_WORKFLOW_NAME = "Test Workflow"; + // NO GITHUB_AW_COMMAND set - this is NOT a command workflow global.context.eventName = "issues"; global.context.payload = { issue: { number: 123 }, repository: { html_url: "https://github.com/testowner/testrepo" }, }; - // Mock reaction call - mockGithub.request - .mockResolvedValueOnce({ - data: { id: 456 }, - }) - // Mock comment creation - .mockResolvedValueOnce({ - data: { id: 789, html_url: "https://github.com/testowner/testrepo/issues/123#issuecomment-789" }, - }); + // Mock reaction call only (no comment creation) + mockGithub.request.mockResolvedValueOnce({ + data: { id: 456 }, + }); // Execute the script await eval(`(async () => { ${reactionScript} })()`); - // Verify comment was created (not edited) + // Verify reaction was added expect(mockGithub.request).toHaveBeenCalledWith( - "POST /repos/testowner/testrepo/issues/123/comments", + "POST /repos/testowner/testrepo/issues/123/reactions", expect.objectContaining({ - body: expect.stringContaining("Agentic [Test Workflow]"), + content: "eyes", }) ); - // Verify outputs - expect(mockCore.setOutput).toHaveBeenCalledWith("comment-id", "789"); - expect(mockCore.setOutput).toHaveBeenCalledWith("comment-url", "https://github.com/testowner/testrepo/issues/123#issuecomment-789"); - expect(mockCore.setOutput).toHaveBeenCalledWith("comment-repo", "testowner/testrepo"); + // Verify comment was NOT created (only 1 call for reaction) + expect(mockGithub.request).toHaveBeenCalledTimes(1); + + // Verify only reaction output was set, not comment outputs + expect(mockCore.setOutput).toHaveBeenCalledWith("reaction-id", "456"); + expect(mockCore.setOutput).not.toHaveBeenCalledWith("comment-id", expect.anything()); }); it("should create new comment for issue_comment event (not edit)", async () => { @@ -391,17 +394,17 @@ describe("add_reaction_and_edit_comment.cjs", () => { // Execute the script await eval(`(async () => { ${reactionScript} })()`); - // Verify new comment was created, NOT edited - // Should be POST to comments endpoint, not GET then PATCH to specific comment + // Verify new comment was created on the issue, NOT on the comment + // Should be POST to issue comments endpoint, not to the specific comment expect(mockGithub.request).toHaveBeenCalledWith( - "POST /repos/testowner/testrepo/issues/comments/456", + "POST /repos/testowner/testrepo/issues/123/comments", expect.objectContaining({ body: expect.stringContaining("Agentic [Test Workflow]"), }) ); - // Verify GET (for editing) was NOT called - expect(mockGithub.request).not.toHaveBeenCalledWith("GET /repos/testowner/testrepo/issues/comments/456", expect.anything()); + // Verify we're not posting to the comment endpoint (which would be wrong) + expect(mockGithub.request).not.toHaveBeenCalledWith("POST /repos/testowner/testrepo/issues/comments/456", expect.anything()); // Verify outputs expect(mockCore.setOutput).toHaveBeenCalledWith("comment-id", "789"); @@ -433,16 +436,17 @@ describe("add_reaction_and_edit_comment.cjs", () => { // Execute the script await eval(`(async () => { ${reactionScript} })()`); - // Verify new comment was created + // Verify new comment was created on the PR, NOT on the review comment + // Should be POST to PR (issues) comments endpoint, not to the specific review comment expect(mockGithub.request).toHaveBeenCalledWith( - "POST /repos/testowner/testrepo/pulls/comments/789", + "POST /repos/testowner/testrepo/issues/456/comments", expect.objectContaining({ body: expect.stringContaining("Agentic [PR Review Bot]"), }) ); - // Verify GET (for editing) was NOT called - expect(mockGithub.request).not.toHaveBeenCalledWith("GET /repos/testowner/testrepo/pulls/comments/789", expect.anything()); + // Verify we're not posting to the review comment endpoint (which would be wrong) + expect(mockGithub.request).not.toHaveBeenCalledWith("POST /repos/testowner/testrepo/pulls/comments/789", expect.anything()); // Verify outputs expect(mockCore.setOutput).toHaveBeenCalledWith("comment-id", "999"); @@ -450,9 +454,10 @@ describe("add_reaction_and_edit_comment.cjs", () => { expect(mockCore.setOutput).toHaveBeenCalledWith("comment-repo", "testowner/testrepo"); }); - it("should create comment on discussion when shouldEditComment is true", async () => { + it("should NOT create comment on discussion (non-command workflow)", async () => { process.env.GITHUB_AW_REACTION = "eyes"; process.env.GITHUB_AW_WORKFLOW_NAME = "Test Workflow"; + // NO GITHUB_AW_COMMAND set - this is NOT a command workflow global.context.eventName = "discussion"; global.context.payload = { discussion: { number: 10 }, @@ -477,43 +482,20 @@ describe("add_reaction_and_edit_comment.cjs", () => { content: "EYES", }, }, - }) - // Mock GraphQL query to get discussion ID again for comment - .mockResolvedValueOnce({ - repository: { - discussion: { - id: "D_kwDOABcD1M4AaBbC", - }, - }, - }) - // Mock GraphQL mutation to add comment - .mockResolvedValueOnce({ - addDiscussionComment: { - comment: { - id: "DC_kwDOABcD1M4AaBbD", - url: "https://github.com/testowner/testrepo/discussions/10#discussioncomment-456", - }, - }, }); // Execute the script await eval(`(async () => { ${reactionScript} })()`); - // Verify comment was created - expect(mockGithub.graphql).toHaveBeenCalledWith( - expect.stringContaining("addDiscussionComment"), - expect.objectContaining({ - dId: "D_kwDOABcD1M4AaBbC", - body: expect.stringContaining("Agentic [Test Workflow]"), - }) - ); + // Verify reaction was added (2 GraphQL calls: get discussion ID + add reaction) + expect(mockGithub.graphql).toHaveBeenCalledTimes(2); - expect(mockCore.setOutput).toHaveBeenCalledWith("comment-id", "DC_kwDOABcD1M4AaBbD"); - expect(mockCore.setOutput).toHaveBeenCalledWith( - "comment-url", - "https://github.com/testowner/testrepo/discussions/10#discussioncomment-456" - ); - expect(mockCore.setOutput).toHaveBeenCalledWith("comment-repo", "testowner/testrepo"); + // Verify comment was NOT created (no addDiscussionComment mutation) + expect(mockGithub.graphql).not.toHaveBeenCalledWith(expect.stringContaining("addDiscussionComment"), expect.anything()); + + // Verify only reaction output was set + expect(mockCore.setOutput).toHaveBeenCalledWith("reaction-id", "MDg6UmVhY3Rpb24xMjM0NTY3ODk="); + expect(mockCore.setOutput).not.toHaveBeenCalledWith("comment-id", expect.anything()); }); it("should create new comment for discussion_comment events", async () => {