feat(post-workflow-hook): pass the result status of executed command to the post hook envs #5308
+186
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
what
The status of the result (whether there were any errors during execution) of the plan/apply command was added to the context and passed to the post workflow hook as an env for use in the shell script.
why
One of our post hook sends a notification to the engineer in Slack after the plan/apply command is completed (we have tools that match VCS and Slack users). This is very useful because user does not need to check with some interval whether the plan/apply is completed. And also it is very difficult to forget about a ready-made plan that blocks some part of the infrastructure, or about an apply that may be successful or unsuccessful.
It is useful to know the general status of the executed command. If the apply was successful, user can check the result without checking the status of the pull request, or the apply failed, user needs to check what happened very quickly, perhaps some error will be critical for the infrastructure. Similarly to a plan, a successful plan can be immediately sent to the team for review without leaving Slack, and a failed plan must be checked so as not to block others (rerun or unlock).
tests
RunPostHooks
sets the status to theWorkflowHookCommandContext
PostWorkflowHookRunner
sets the status as envreferences