diff --git a/actions/setup/js/close_issue.cjs b/actions/setup/js/close_issue.cjs index 2437f43024d..57d7ab1bdb9 100644 --- a/actions/setup/js/close_issue.cjs +++ b/actions/setup/js/close_issue.cjs @@ -8,7 +8,7 @@ const { resolveTargetRepoConfig, resolveAndValidateRepo, validateRepo } = require("./repo_helpers.cjs"); const { createAuthenticatedGitHubClient } = require("./handler_auth.cjs"); const { ERR_NOT_FOUND } = require("./error_codes.cjs"); -const { createCloseEntityHandler, ISSUE_CONFIG } = require("./close_entity_helpers.cjs"); +const { createCloseEntityHandler, buildCommentBody, ISSUE_CONFIG } = require("./close_entity_helpers.cjs"); const { loadTemporaryIdMapFromResolved, resolveRepoIssueTarget } = require("./temporary_id.cjs"); const { getErrorMessage } = require("./error_helpers.cjs"); const { normalizeIssueIntentMetadata } = require("./issue_intents.cjs"); @@ -297,8 +297,9 @@ async function main(config = {}) { }, buildCommentBody(sanitizedBody) { - // Issues post the sanitized body directly without a workflow footer - return sanitizedBody; + const triggeringIssueNumber = context.payload?.issue?.number; + const triggeringPRNumber = context.payload?.pull_request?.number; + return buildCommentBody(sanitizedBody, triggeringIssueNumber, triggeringPRNumber); }, addComment: addIssueComment, diff --git a/actions/setup/js/close_issue.test.cjs b/actions/setup/js/close_issue.test.cjs index f58a173a2d2..b31405ce66c 100644 --- a/actions/setup/js/close_issue.test.cjs +++ b/actions/setup/js/close_issue.test.cjs @@ -383,6 +383,8 @@ describe("close_issue", () => { expect(result.success).toBe(true); expect(commentCalls.length).toBe(1); expect(commentCalls[0].body).toContain("This issue is being closed automatically"); + expect(commentCalls[0].body).toContain("for #123"); + expect(commentCalls[0].body).toContain("gh-aw-agentic-workflow:"); }); it("should use body field from message over config comment", async () => { @@ -413,7 +415,9 @@ describe("close_issue", () => { expect(result.success).toBe(true); expect(commentCalls.length).toBe(1); // Should use the body from message, not the config comment - expect(commentCalls[0].body).toBe("Custom body from message"); + expect(commentCalls[0].body).toContain("Custom body from message"); + expect(commentCalls[0].body).toContain("for #123"); + expect(commentCalls[0].body).toContain("gh-aw-agentic-workflow:"); expect(commentCalls[0].body).not.toContain("Default comment from config"); }); @@ -506,7 +510,7 @@ describe("close_issue", () => { expect(result.success).toBe(true); expect(result.alreadyClosed).toBe(true); - expect(commentBody).toBe("Closing comment with details"); + expect(commentBody).toContain("Closing comment with details"); expect(issueUpdateCalled).toBe(false); // Should not call update for already closed issue });