From 4e5d7569e5047eaac5a8236c502f83adbb824818 Mon Sep 17 00:00:00 2001 From: Yordan Ibishev Date: Tue, 13 Jul 2021 17:54:25 +0100 Subject: [PATCH] feat(action): Support detailed exit codes. This should allow plans to succeed using the terraform_wrapper functionality whenever an exit code of 2 is returned. https://www.terraform.io/docs/cli/commands/plan.html#detailed-exitcode - This is useful for adding custom steps in our GitHub action workflows. - Not a Javascript developer so Im not sure how valid the OR condition is. --- wrapper/terraform.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wrapper/terraform.js b/wrapper/terraform.js index 68ee962..69f93af 100755 --- a/wrapper/terraform.js +++ b/wrapper/terraform.js @@ -42,7 +42,8 @@ async function checkTerraform () { core.setOutput('exitcode', exitCode.toString(10)); // A non-zero exitCode is considered an error - if (exitCode !== 0) { + // An exit-code 2 is used when the '-detailed-exitcode' option is passed to plan. this denotes Success with non-empty diff (changes present) + if (exitCode !== 0 || exitCode !== 2 ) { core.setFailed(`Terraform exited with code ${exitCode}.`); } })();