Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(post-workflow-hook): pass the result status of executed command to the post hook envs #5308

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

a1k0u
Copy link
Contributor

@a1k0u a1k0u commented Feb 8, 2025

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

  • We also use a post-hook to notify user of a completed plan/apply
  • Knowing the completed status of the plan/apply command will help us to optimize transitions between the chat platform and VSC depending on the status

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

  • I have checked that the plan/apply runners set the result status to the context
  • I have checked that RunPostHooks sets the status to the WorkflowHookCommandContext
  • I have checked that PostWorkflowHookRunner sets the status as env

references

@a1k0u a1k0u requested review from a team as code owners February 8, 2025 16:40
@a1k0u a1k0u requested review from chenrui333, lukemassa and nitrocode and removed request for a team February 8, 2025 16:40
@dosubot dosubot bot added feature New functionality/enhancement go Pull requests that update Go code labels Feb 8, 2025
@a1k0u a1k0u force-pushed the add-env-to-post-hook branch 2 times, most recently from 892c5b8 to 8da3723 Compare February 8, 2025 16:49
@a1k0u a1k0u marked this pull request as draft February 8, 2025 17:08
@a1k0u a1k0u marked this pull request as ready for review February 8, 2025 17:17
@X-Guardian
Copy link
Contributor

Hi @a1k0u, can you also update the docs: https://github.com/runatlantis/atlantis/blob/main/runatlantis.io/docs/post-workflow-hooks.md

@X-Guardian X-Guardian added the waiting-on-response Waiting for a response from the user label Feb 10, 2025
@github-actions github-actions bot added the docs Documentation label Feb 10, 2025
@a1k0u a1k0u force-pushed the add-env-to-post-hook branch from afa3d61 to c29c295 Compare February 10, 2025 19:31
@github-actions github-actions bot added dependencies PRs that update a dependency file github-actions labels Feb 10, 2025
@a1k0u a1k0u force-pushed the add-env-to-post-hook branch from 6b53c74 to e9665f6 Compare February 10, 2025 19:43
@a1k0u
Copy link
Contributor Author

a1k0u commented Feb 10, 2025

@X-Guardian, thanks! I've added info about new env

Copy link
Contributor

@X-Guardian X-Guardian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @a1k0u. Thanks for this.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 10, 2025
@X-Guardian X-Guardian merged commit 1f9b90e into runatlantis:main Feb 10, 2025
39 checks passed
tufitko pushed a commit to tufitko/atlantis that referenced this pull request Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies PRs that update a dependency file docs Documentation feature New functionality/enhancement github-actions go Pull requests that update Go code lgtm This PR has been approved by a maintainer waiting-on-response Waiting for a response from the user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants