fix(DNRY): Moving isGitHubActions to the module context (expensive operation), and the condition to updateSummary().
This commit is contained in:
@@ -106431,6 +106431,7 @@ var addTools = (ctx, server, tools) => {
|
||||
|
||||
// mcp/comment.ts
|
||||
var LEAPING_INTO_ACTION_PREFIX = "Leaping into action";
|
||||
var isGitHubActions2 = !!process.env.GITHUB_ACTIONS;
|
||||
async function buildCommentFooter({
|
||||
payload,
|
||||
octokit,
|
||||
@@ -106559,12 +106560,11 @@ function setProgressCommentId(id) {
|
||||
var ReportProgress = type({
|
||||
body: type.string.describe("the progress update content to share")
|
||||
});
|
||||
var updateSummary = (text) => core3.summary.addRaw(text).write({ overwrite: true });
|
||||
var updateSummary = (text) => isGitHubActions2 && core3.summary.addRaw(text).write({ overwrite: true });
|
||||
async function reportProgress(ctx, { body }) {
|
||||
const existingCommentId = getProgressCommentId();
|
||||
const issueNumber = ctx.toolState.prNumber ?? ctx.toolState.issueNumber ?? ctx.payload.event.issue_number;
|
||||
const isPlanMode = ctx.toolState.selectedMode === "Plan";
|
||||
const isGitHubActions2 = !!process.env.GITHUB_ACTIONS;
|
||||
if (existingCommentId) {
|
||||
const customParts = isPlanMode && issueNumber !== void 0 ? [buildImplementPlanLink(ctx.owner, ctx.name, issueNumber, existingCommentId)] : void 0;
|
||||
const bodyWithoutFooter = stripExistingFooter(body);
|
||||
@@ -106581,7 +106581,7 @@ async function reportProgress(ctx, { body }) {
|
||||
body: bodyWithFooter
|
||||
});
|
||||
progressCommentWasUpdated = true;
|
||||
if (isGitHubActions2) await updateSummary(bodyWithFooter);
|
||||
await updateSummary(bodyWithFooter);
|
||||
return {
|
||||
commentId: result2.data.id,
|
||||
url: result2.data.html_url,
|
||||
@@ -106616,7 +106616,7 @@ async function reportProgress(ctx, { body }) {
|
||||
comment_id: result.data.id,
|
||||
body: bodyWithPlanLink
|
||||
});
|
||||
if (isGitHubActions2) await updateSummary(bodyWithPlanLink);
|
||||
await updateSummary(bodyWithPlanLink);
|
||||
return {
|
||||
commentId: updateResult.data.id,
|
||||
url: updateResult.data.html_url,
|
||||
@@ -106624,7 +106624,7 @@ async function reportProgress(ctx, { body }) {
|
||||
action: "created"
|
||||
};
|
||||
}
|
||||
if (isGitHubActions2) await updateSummary(initialBody);
|
||||
await updateSummary(initialBody);
|
||||
return {
|
||||
commentId: result.data.id,
|
||||
url: result.data.html_url,
|
||||
|
||||
+7
-6
@@ -15,6 +15,8 @@ import { execute, tool } from "./shared.ts";
|
||||
*/
|
||||
export const LEAPING_INTO_ACTION_PREFIX = "Leaping into action";
|
||||
|
||||
const isGitHubActions = !!process.env.GITHUB_ACTIONS;
|
||||
|
||||
interface BuildCommentFooterParams {
|
||||
payload: Payload;
|
||||
octokit?: OctokitWithPlugins | undefined;
|
||||
@@ -190,8 +192,8 @@ export const ReportProgress = type({
|
||||
});
|
||||
|
||||
|
||||
/** Updates job summary with the given text. */
|
||||
const updateSummary = (text: string) => core.summary.addRaw(text).write({ overwrite: true });
|
||||
/** Updates job summary with the given text if running in GitHub Actions. */
|
||||
const updateSummary = (text: string) => isGitHubActions && core.summary.addRaw(text).write({ overwrite: true });
|
||||
|
||||
/**
|
||||
* Standalone function to report progress to GitHub comment.
|
||||
@@ -214,7 +216,6 @@ export async function reportProgress(
|
||||
const issueNumber =
|
||||
ctx.toolState.prNumber ?? ctx.toolState.issueNumber ?? ctx.payload.event.issue_number;
|
||||
const isPlanMode = ctx.toolState.selectedMode === "Plan";
|
||||
const isGitHubActions = !!process.env.GITHUB_ACTIONS;
|
||||
|
||||
// if we already have a progress comment, update it
|
||||
if (existingCommentId) {
|
||||
@@ -240,7 +241,7 @@ export async function reportProgress(
|
||||
|
||||
progressCommentWasUpdated = true;
|
||||
|
||||
if (isGitHubActions) await updateSummary(bodyWithFooter);
|
||||
await updateSummary(bodyWithFooter);
|
||||
|
||||
return {
|
||||
commentId: result.data.id,
|
||||
@@ -289,7 +290,7 @@ export async function reportProgress(
|
||||
body: bodyWithPlanLink,
|
||||
});
|
||||
|
||||
if (isGitHubActions) await updateSummary(bodyWithPlanLink);
|
||||
await updateSummary(bodyWithPlanLink);
|
||||
|
||||
return {
|
||||
commentId: updateResult.data.id,
|
||||
@@ -299,7 +300,7 @@ export async function reportProgress(
|
||||
};
|
||||
}
|
||||
|
||||
if (isGitHubActions) await updateSummary(initialBody);
|
||||
await updateSummary(initialBody);
|
||||
|
||||
return {
|
||||
commentId: result.data.id,
|
||||
|
||||
Reference in New Issue
Block a user