From 3e527234ccf8ca494450942c4a91d54b291b013e Mon Sep 17 00:00:00 2001 From: mponaws <157431286+mponaws@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:31:48 -0700 Subject: [PATCH] Return with exit code on failure (#8) --- main.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 6bbd726..0acebb9 100644 --- a/main.py +++ b/main.py @@ -68,8 +68,7 @@ def main(): ["--config", get_config()] ) # Config is required for handling terraform templates result = execute_command(command_lst) - formatted_result = format_result(result) - set_github_action_output(ACTION_OUTPUT_RESULT, formatted_result) + set_output(result) return @@ -189,16 +188,20 @@ def execute_command(command): err.returncode, err.with_traceback, err.output ) ) - if err.returncode == 2: - return err.output - + set_output(err.output) raise except Exception as err: print(f"Unexpected {err=}, {type(err)=}") raise +def set_output(val): + formatted_result = format_result(val) + set_github_action_output(ACTION_OUTPUT_RESULT, formatted_result) + return + + def format_result(result): result = re.sub(r"[\n\t\s]*", "", result) print("result={}".format(result))