Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions actions/setup/js/add_comment.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions actions/setup/js/add_comment.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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("<!-- malicious comment -->");
Expand Down Expand Up @@ -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");
});
});
});
Expand Down