mirror of
https://github.com/hashicorp/setup-terraform.git
synced 2025-12-15 16:12:35 +00:00
Support detailed exit codes. (#125)
* 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. Co-authored-by: James Pogran <jpogran@outlook.com>
This commit is contained in:
parent
d6a45b7634
commit
62a66eef78
2 changed files with 18 additions and 6 deletions
12
dist/index1.js
vendored
12
dist/index1.js
vendored
|
|
@ -3069,10 +3069,16 @@ async function checkTerraform () {
|
|||
core.setOutput('stderr', stderr.contents);
|
||||
core.setOutput('exitcode', exitCode.toString(10));
|
||||
|
||||
// A non-zero exitCode is considered an error
|
||||
if (exitCode !== 0) {
|
||||
core.setFailed(`Terraform exited with code ${exitCode}.`);
|
||||
if (exitCode === 0 || exitCode === 2) {
|
||||
// A exitCode of 0 is considered a success
|
||||
// An exitCode of 2 may be returned when the '-detailed-exitcode' option
|
||||
// is passed to plan. This denotes Success with non-empty
|
||||
// diff (changes present).
|
||||
return;
|
||||
}
|
||||
|
||||
// A non-zero exitCode is considered an error
|
||||
core.setFailed(`Terraform exited with code ${exitCode}.`);
|
||||
})();
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -41,8 +41,14 @@ async function checkTerraform () {
|
|||
core.setOutput('stderr', stderr.contents);
|
||||
core.setOutput('exitcode', exitCode.toString(10));
|
||||
|
||||
// A non-zero exitCode is considered an error
|
||||
if (exitCode !== 0) {
|
||||
core.setFailed(`Terraform exited with code ${exitCode}.`);
|
||||
if (exitCode === 0 || exitCode === 2) {
|
||||
// A exitCode of 0 is considered a success
|
||||
// An exitCode of 2 may be returned when the '-detailed-exitcode' option
|
||||
// is passed to plan. This denotes Success with non-empty
|
||||
// diff (changes present).
|
||||
return;
|
||||
}
|
||||
|
||||
// A non-zero exitCode is considered an error
|
||||
core.setFailed(`Terraform exited with code ${exitCode}.`);
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue