Skip to content

Commit bb87bf5

Browse files
committed
Fix output swallowed when wrapper enabled
Presently using a command such as `terraform output -json | jq` does not work with the wrapper enabled, as it is by default. In order to consume terraform's output having set it up with this Action, it is necessary either to disable the wrapper (`with: terraform_wrapper: false`) or run it in its own Actions step with an explicit `id` (e.g. `id: foo`) so that it can be referred to and consumed (`${{steps.foo.outputs.stdout}}` et al.) in later steps. This seems to be the result of much confusion (issues passim) and is not at all easy (#338) to debug/diagnose and come to the realisation that it's due to the wrapper, or even that such a thing exists. This commit aims to address the issue by passing through stdout & stderr, so that they're available in Unix pipelines and variable assignment etc. as expected within a single step, while still retaining the wrapper's listening behaviour to provide them as Actions outputs. Closes #20, #80, #85, #149, #338, and probably more.
1 parent 599d383 commit bb87bf5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

wrapper/terraform.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ async function checkTerraform () {
4646
core.setOutput('stderr', stderr.contents);
4747
core.setOutput('exitcode', exitCode.toString(10));
4848

49+
// Pass-through stdout/err in case we're being used in a pipeline or variable assignment
50+
process.stdout.write(stdout.contents);
51+
process.stderr.write(stderr.contents);
52+
4953
if (exitCode === 0 || exitCode === 2) {
5054
// A exitCode of 0 is considered a success
5155
// An exitCode of 2 may be returned when the '-detailed-exitcode' option

0 commit comments

Comments
 (0)