From 3fb381ded9287ee76719b82c90b2fe6e271f0ebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Vassb=C3=B8?= Date: Wed, 29 Jan 2020 16:05:09 +0100 Subject: [PATCH] Let plan action output the plan-output (#119) * Ouput the plan output for subsequent actions * Follow Github's recommendation for mulit-line string output Co-Authored-By: Matthew Sanabria <24284972+sudomateo@users.noreply.github.com> Co-authored-by: Matthew Sanabria <24284972+sudomateo@users.noreply.github.com> --- README.md | 1 + action.yml | 2 ++ src/terraform_plan.sh | 7 +++++++ 3 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 401a169d..6772db95 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index 68163a7c..b4aca24f 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/src/terraform_plan.sh b/src/terraform_plan.sh index 4f569dad..384d1b8e 100755 --- a/src/terraform_plan.sh +++ b/src/terraform_plan.sh @@ -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} }