Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Let plan action output the plan-output (#119)
Browse files Browse the repository at this point in the history
* Ouput the plan output for subsequent actions

* Follow Github's recommendation for mulit-line string output

Co-Authored-By: Matthew Sanabria <[email protected]>

Co-authored-by: Matthew Sanabria <[email protected]>
  • Loading branch information
jvassbo and sudomateo authored Jan 29, 2020
1 parent 8b26ef2 commit 3fb381d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Outputs are used to pass information to subsequent GitHub Actions steps.

* `tf_actions_output` - The Terraform outputs in JSON format.
* `tf_actions_plan_has_changes` - Whether or not the Terraform plan contained changes.
* `tf_actions_plan_output` - The Terraform plan output.

## Secrets

Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ outputs:
description: 'The Terraform outputs in JSON format.'
tf_actions_plan_has_changes:
description: 'Whether or not the Terraform plan contained changes.'
tf_actions_plan_output:
description: 'The Terraform plan output.'
runs:
using: 'docker'
image: './Dockerfile'
7 changes: 7 additions & 0 deletions src/terraform_plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,12 @@ ${planOutput}
fi

echo ::set-output name=tf_actions_plan_has_changes::${planHasChanges}

# https://github.community/t5/GitHub-Actions/set-output-Truncates-Multiline-Strings/m-p/38372/highlight/true#M3322
planOutput="${planOutput//'%'/'%25'}"
planOutput="${planOutput//$'\n'/'%0A'}"
planOutput="${planOutput//$'\r'/'%0D'}"

echo "::set-output name=tf_actions_plan_output::${planOutput}"
exit ${planExitCode}
}

0 comments on commit 3fb381d

Please sign in to comment.