Skip to content

Commit

Permalink
Return with exit code on failure (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
mponaws authored Apr 15, 2024
1 parent 666e9c2 commit 3e52723
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 3e52723

Please sign in to comment.