Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log stderr from commands. #1324

Merged
merged 1 commit into from
Dec 24, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- fix: Make `pulumi login` respect configuration in `Pulumi.yaml`
([#1299](https://github.com/pulumi/actions/pull/1299))
- fix: Log stderr from commands
([#1316](https://github.com/pulumi/actions/issues/1316))

---

Expand Down
23 changes: 13 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,31 @@ const runAction = async (config: Config): Promise<void> => {

core.startGroup(`pulumi ${config.command} on ${config.stackName}`);

const actions: Record<Commands, () => Promise<string>> = {
up: () => stack.up({ onOutput, ...config.options }).then((r) => r.stdout),
const actions: Record<Commands, () => Promise<[string, string]>> = {
up: () => stack.up({ onOutput, ...config.options }).then((r) => [r.stdout, r.stderr]),
update: () =>
stack.up({ onOutput, ...config.options }).then((r) => r.stdout),
stack.up({ onOutput, ...config.options }).then((r) => [r.stdout, r.stderr]),
refresh: () =>
stack.refresh({ onOutput, ...config.options }).then((r) => r.stdout),
stack.refresh({ onOutput, ...config.options }).then((r) => [r.stdout, r.stderr]),
destroy: () =>
stack.destroy({ onOutput, ...config.options }).then((r) => r.stdout),
stack.destroy({ onOutput, ...config.options }).then((r) => [r.stdout, r.stderr]),
preview: async () => {
const { stdout, stderr } = await stack.preview(config.options);
onOutput(stdout);
onOutput(stderr);
return stdout;
return [stdout, stderr];
},
output: () => new Promise(() => '') //do nothing, outputs are fetched anyway afterwards
};

core.debug(`Running action ${config.command}`);
const output = await actions[config.command]();
const [stdout, stderr] = await actions[config.command]();
core.debug(`Done running action ${config.command}`);
if (stderr !== '') {
core.warning(stderr);
}

core.setOutput('output', output);
core.setOutput('output', stdout);

const outputs = await stack.outputs();

Expand All @@ -120,13 +123,13 @@ const runAction = async (config: Config): Promise<void> => {
(config.commentOnPr && isPullRequest)) {
core.debug(`Commenting on pull request`);
invariant(config.githubToken, 'github-token is missing.');
handlePullRequestMessage(config, projectName, output);
handlePullRequestMessage(config, projectName, stdout);
}

if (config.commentOnSummary) {
await core.summary
.addHeading(`Pulumi ${config.stackName} results`)
.addCodeBlock(output, "diff")
.addCodeBlock(stdout, "diff")
.write();
}

Expand Down
Loading