Skip to content

Commit 9939478

Browse files
authored
fix(USE-003): emit staged mode preview summary in upload_artifact handler (#26313)
1 parent b8e0b8a commit 9939478

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

actions/setup/js/upload_artifact.cjs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,20 @@ async function main(config = {}) {
565565
};
566566
}
567567
} else {
568-
core.info(`Staged mode: skipping artifact upload for slot ${i}`);
568+
// Emit a staged mode preview summary.
569+
let summaryContent = "## 🎭 Staged Mode: Upload Artifact Preview\n\n";
570+
summaryContent += "The following artifact upload would be performed if staged mode was disabled:\n\n";
571+
summaryContent += `**Artifact Name:** ${artifactName}\n\n`;
572+
summaryContent += `**Files (${files.length}):**\n\n`;
573+
for (const file of files) {
574+
summaryContent += `- \`${file}\`\n`;
575+
}
576+
summaryContent += `\n**Total Size:** ${totalSize} bytes\n\n`;
577+
summaryContent += `**Retention:** ${retentionDays} days\n\n`;
578+
summaryContent += `> ℹ️ Upload skipped (staged mode active)\n\n`;
579+
580+
await core.summary.addRaw(summaryContent).write();
581+
core.info("📝 Upload artifact preview written to step summary");
569582
}
570583

571584
// Set step outputs so downstream jobs can reference the tmp ID.

actions/setup/js/upload_artifact.test.cjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,20 @@ describe("upload_artifact.cjs", () => {
398398
expect(results[0].success).toBe(true);
399399
expect(mockArtifactClient.uploadArtifact).not.toHaveBeenCalled();
400400
});
401+
402+
it("emits a staged mode preview summary when staged mode is active", async () => {
403+
process.env.GH_AW_SAFE_OUTPUTS_STAGED = "true";
404+
writeStaging("output.json");
405+
406+
await runHandler(buildConfig(), [{ type: "upload_artifact", path: "output.json" }]);
407+
408+
expect(mockCore.summary.addRaw).toHaveBeenCalled();
409+
const summaryContent = mockCore.summary.addRaw.mock.calls[0][0];
410+
expect(summaryContent).toContain("🎭 Staged Mode");
411+
expect(summaryContent).toContain("Upload Artifact Preview");
412+
expect(summaryContent).toContain("output.json");
413+
expect(mockCore.summary.write).toHaveBeenCalled();
414+
});
401415
});
402416

403417
describe("resolver file", () => {

0 commit comments

Comments
 (0)