From 92c5bad2b816be1b4fdf293d8186c895d1409d97 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 15 Feb 2026 17:36:33 +0000 Subject: [PATCH] fix: Use generateFooterWithMessages in add_comment to respect custom footer config The add_comment.cjs file was using a hardcoded footer instead of the generateFooterWithMessages function, which prevented custom footer configurations from being applied. This change: - Replaces hardcoded footer with generateFooterWithMessages call - Adds workflow source and triggering context to footer generation - Updates test expectations to match new footer format Fixes the issue where workflows with custom footer messages in the messages.footer configuration were not being applied to comments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- actions/setup/js/add_comment.cjs | 15 +++++++++------ actions/setup/js/add_comment.test.cjs | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) 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"); }); }); });