mergeable
mergeable copied to clipboard
feature request: validate on the content of the last comment added
This will allow you to trigger actions based on the contents of a comment, possibly by at-mentioning the bot.
This sounds interesting. Could you clarify on the use case in which you find this useful?
I like this as well. Possible things that I can imagine - Auto merge PRs or add labels or add specific comments based on a command by a user. I am guessing apart from the last comment validator, we would also want some way to capture regex groups from the comment to be used in an action.
@samj1912 described a lot of the capabilities I was thinking of. Coupled with other validators and the available actions this will open up a lot of possibilities.
We are trying to implement a worklow where we want a comment to be the trigger for the deployment, like a bot (ex: Atlantis). This would actually be really nice!
We are trying to implement a worklow where we want a comment to be the trigger for the deployment, like a bot (ex: Atlantis). This would actually be really nice!
I second this. Today we had a failure that could have been prevented if we had a way of identifying the contents of a particular comment to request a review from another team.
The use-case
To be more precise, this was about using Terraform.
So, we have an action that uses Terraform on the backend. When a PR is submitted, the action triggers a terraform plan
command. When the plan finishes, its result is written as a comment on the PR by a bot.
The terraform's plan is nothing more than a set of actions (create, update and destroy) that will be executed against the infrastructure when the subsequent command terraform apply
is ran - this is something that usually happens after manually reviewing the plan.
So, where does mergeable can help?
If we could use mergeable to test/search for a pattern on the comment, we could detect when terraform wants to destroy resources, and if that is the case, we could request an extra review from another team to prevent a potential disaster 😁
@calexandre I think it's a great use case, maybe even only validate the content if the author
matches the settings (terraform in this case). I personally don't think I'll be able to get to it anytime soon. If you decided to create a PR for this feature, I'll do my best to get it merged asap.
@calexandre I think it's a great use case, maybe even only validate the content if the
author
matches the settings (terraform in this case). I personally don't think I'll be able to get to it anytime soon. If you decided to create a PR for this feature, I'll do my best to get it merged asap.
Thank you @shine2lay
I'd be happy to!
Could you just give some pointers on how can I contribute to implement such feature?
After looking a bit through the code, I would start by extending the validator
class. Is there any particular validator that you recommend to use as an example to guide me through?
@calexandre I think you'll have to create a Comment
validator, which should extract the comment body
from the payload
(maybe fetch the comment if it's not in the payload) and use the options_processor
which will do the sub option processing like must_includes
, must_excludes
, etc...
In terms of existing validator, description
would be the easiest to understand how to utilize options_processor
, browse a few others ones like contents
to see how you can make a github call and then use options_processor
The feature was added recently: https://github.com/mergeability/mergeable/pull/668
@abid-mujtaba the feature got implemented. Mergeable actions can be triggered by comments. Can you close the issue?