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

Add COMMENT_ARGS to Pre/Post-Workflow Hook Execution Environment #2621

Merged

Conversation

adam-verigin
Copy link
Contributor

Summary

This adds the COMMENT_ARGS environment variable to pre/post workflow hook execution environments, using the same escaping as for regular workflow steps.

Use Case

At my workplace, we normally unlock projects after developers run atlantis plan since only operators can run applies in most environments (for compliance reasons) and this helps alleviate lock-contention issues. We do this using a post-workflow hook.

However, there are some scenarios where we want to allow developers to conditionally keep their plans. My idea was to use atlantis plan -- --keep-locks and handle the logic in the post-workflow hook; however, that doesn't work because post-workflow hooks don't get COMMENT_ARGS. I also tried moving the unlocking step to a workflow step, but that fails to delete the plan files:

unable to obtain working dir lock when trying to delete old plans: The default workspace at path foo/bar is currently locked by another command that is running for this pull request.
Wait until the previous command is complete and try again. 

So it seems I need to keep the unlocking logic in a post-workflow hook.

@adam-verigin adam-verigin requested a review from a team as a code owner October 25, 2022 21:18
@jamengual jamengual added waiting-on-review Waiting for a review from a maintainer github-actions labels Oct 27, 2022
@adam-verigin
Copy link
Contributor Author

Now that this has 2 approvals, is there anything blocking it from being merged? (I can' because I don't have write access).

@nitrocode nitrocode merged commit c3462f9 into runatlantis:master Nov 7, 2022
@nitrocode
Copy link
Member

Thanks @adam-verigin!

@adam-verigin adam-verigin deleted the comment_args_for_workflow_hooks branch November 7, 2022 20:51
@nitrocode nitrocode added this to the 0.21.0 milestone Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github-actions waiting-on-review Waiting for a review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants