diff --git a/dist/index1.js b/dist/index1.js index 976a901..1e4a9a0 100755 --- a/dist/index1.js +++ b/dist/index1.js @@ -3040,7 +3040,7 @@ async function checkTerraform () { return io.which(pathToCLI, check); } -(async () => { +async () => { // This will fail if Terraform isn't found, which is what we want await checkTerraform(); @@ -3049,14 +3049,14 @@ async function checkTerraform () { const stderr = new OutputListener(); const listeners = { stdout: stdout.listener, - stderr: stderr.listener + stderr: stderr.listener, }; // Execute terraform and capture output const args = process.argv.slice(2); const options = { listeners, - ignoreReturnCode: true + ignoreReturnCode: true, }; const exitCode = await exec(pathToCLI, args, options); core.debug(`Terraform exited with code ${exitCode}.`); @@ -3065,15 +3065,21 @@ async function checkTerraform () { core.debug(`exitcode: ${exitCode}`); // Set outputs, result, exitcode, and stderr - core.setOutput('stdout', stdout.contents); - core.setOutput('stderr', stderr.contents); - core.setOutput('exitcode', exitCode.toString(10)); + core.setOutput("stdout", stdout.contents); + core.setOutput("stderr", stderr.contents); + core.setOutput("exitcode", exitCode.toString(10)); + + 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 - if (exitCode !== 0) { - core.setFailed(`Terraform exited with code ${exitCode}.`); - } -})(); + core.setFailed(`Terraform exited with code ${exitCode}.`); +}; })(); diff --git a/wrapper/terraform.js b/wrapper/terraform.js index 30dc3ed..fd903dd 100755 --- a/wrapper/terraform.js +++ b/wrapper/terraform.js @@ -12,7 +12,7 @@ async function checkTerraform () { return io.which(pathToCLI, check); } -(async () => { +async () => { // This will fail if Terraform isn't found, which is what we want await checkTerraform(); @@ -21,14 +21,14 @@ async function checkTerraform () { const stderr = new OutputListener(); const listeners = { stdout: stdout.listener, - stderr: stderr.listener + stderr: stderr.listener, }; // Execute terraform and capture output const args = process.argv.slice(2); const options = { listeners, - ignoreReturnCode: true + ignoreReturnCode: true, }; const exitCode = await exec(pathToCLI, args, options); core.debug(`Terraform exited with code ${exitCode}.`); @@ -37,13 +37,18 @@ async function checkTerraform () { core.debug(`exitcode: ${exitCode}`); // Set outputs, result, exitcode, and stderr - core.setOutput('stdout', stdout.contents); - core.setOutput('stderr', stderr.contents); - core.setOutput('exitcode', exitCode.toString(10)); + core.setOutput("stdout", stdout.contents); + core.setOutput("stderr", stderr.contents); + core.setOutput("exitcode", exitCode.toString(10)); + + 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 - // An exit-code 2 may be returned 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}.`); - } -})(); + core.setFailed(`Terraform exited with code ${exitCode}.`); +};