diff --git a/actions/setup/js/add_comment.cjs b/actions/setup/js/add_comment.cjs index 7e639962190..8e5584270b1 100644 --- a/actions/setup/js/add_comment.cjs +++ b/actions/setup/js/add_comment.cjs @@ -488,13 +488,16 @@ async function main(config = {}) { const workflowName = process.env.GH_AW_WORKFLOW_NAME || "Workflow"; const runId = context.runId; const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`; - processedBody += `\n\n> AI generated by [${workflowName}](${runUrl})`; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE ?? ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL ?? ""; - // Add missing tools and data sections if available - const missingInfoSections = getMissingInfoSections(); - if (missingInfoSections) { - processedBody += missingInfoSections; - } + // Get triggering context for footer + const triggeringIssueNumber = context.payload.issue?.number; + const triggeringPRNumber = context.payload.pull_request?.number; + const triggeringDiscussionNumber = context.payload.discussion?.number; + + // Use generateFooterWithMessages to respect custom footer configuration + processedBody += generateFooterWithMessages(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringIssueNumber, triggeringPRNumber, triggeringDiscussionNumber).trimEnd(); // Enforce max limits again after adding footer and metadata // This ensures the final body (including generated content) doesn't exceed limits diff --git a/actions/setup/js/add_comment.test.cjs b/actions/setup/js/add_comment.test.cjs index 921492a8be1..d0364312c9a 100644 --- a/actions/setup/js/add_comment.test.cjs +++ b/actions/setup/js/add_comment.test.cjs @@ -1169,8 +1169,8 @@ describe("add_comment", () => { expect(result.success).toBe(true); expect(capturedBody).toBeDefined(); - // Verify AI footer is present (not removed by sanitization) - expect(capturedBody).toContain("AI generated by"); + // Verify footer is present (not removed by sanitization) + expect(capturedBody).toContain("Generated by"); expect(capturedBody).toContain("Security Test Workflow"); // Verify malicious comment in user content was removed by sanitization expect(capturedBody).not.toContain(""); @@ -1211,7 +1211,7 @@ describe("add_comment", () => { expect(capturedBody).toContain("(evil.com/redacted)"); // HTTP URL redacted // But footer should still be present with proper markdown - expect(capturedBody).toContain("> AI generated by"); + expect(capturedBody).toContain("> Generated by"); }); }); });