mergeable icon indicating copy to clipboard operation
mergeable copied to clipboard

feature request: validate on the content of the last comment added

Open abid-mujtaba opened this issue 3 years ago • 8 comments

This will allow you to trigger actions based on the contents of a comment, possibly by at-mentioning the bot.

abid-mujtaba avatar Oct 06 '20 02:10 abid-mujtaba

This sounds interesting. Could you clarify on the use case in which you find this useful?

jusx avatar Oct 06 '20 05:10 jusx

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 avatar Oct 06 '20 08:10 samj1912

@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.

abid-mujtaba avatar Oct 06 '20 13:10 abid-mujtaba

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!

dgteixeira avatar Dec 29 '21 12:12 dgteixeira

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 avatar Feb 02 '22 19:02 calexandre

@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.

shine2lay avatar Feb 02 '22 20:02 shine2lay

@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 avatar Feb 02 '22 21:02 calexandre

@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

shine2lay avatar Feb 02 '22 23:02 shine2lay

The feature was added recently: https://github.com/mergeability/mergeable/pull/668

cuong-tech avatar Oct 27 '22 14:10 cuong-tech

@abid-mujtaba the feature got implemented. Mergeable actions can be triggered by comments. Can you close the issue?

andekande avatar Jun 07 '23 09:06 andekande