automerge-action icon indicating copy to clipboard operation
automerge-action copied to clipboard

Use repository_dispatch event to trigger events for merged PRs

Open llucax opened this issue 5 years ago • 7 comments
trafficstars

The limitation of actions not being run for pushes done by this action is a bit annoying, as merge commits are not tested.

GiHub offers a repository_dispatch event that can be used to trigger actions manually using a GitHub API call to generate the event.

I wonder if this mechanism can be integrated into this action, so to make sure other actions are ran for merges, one just need to add one more on: event trigger including repository_dispatch.

llucax avatar Oct 15 '20 10:10 llucax

This is already integrated: https://github.com/pascalgn/automerge-action/blob/master/lib/api.js#L73

It's also included in the list of supported events: https://github.com/pascalgn/automerge-action#supported-events

pascalgn avatar Oct 16 '20 07:10 pascalgn

I'm not sure if we are talking about the same thing. If I understand correctly, that is so the automerge action is run on repository_dispatch, right? What I want is the automerge action to trigger the repository_dispatch event, so I can use it as a trigger for my own actions that I want to be run when a PR is auto-merged.

I'm still a bit new to GitHub actions so I'm not sure if I am making sense, but what I actually want is to workaround this limitation: When a pull request is merged by this action, the merge will not trigger other GitHub workflows. by having some configuration to tell the automerge action to create a repository_dispatch event, with a, (possibly configurable) event_type: "automerged".

Would that be possible?

llucax avatar Oct 16 '20 09:10 llucax

The workflow_run event is always triggered by this action (as all other actions). I've updated the README accordingly.

pascalgn avatar Oct 22 '20 16:10 pascalgn

Hi @pascalgn, I still find it hard to see how I can do what I request here. If in my test/deploy workflow I act upon a workflow_run (completed) for the automerge workflow for example, how do I know if the PR was actually merged or the automerge workflow just ran but all the automerge conditions weren't met? Is there any repository you know that has what I am requesting implemented so I can have a look to a full working example?

Thanks!

llucax avatar Oct 22 '20 20:10 llucax

When I use this action to automerge a PR (using squash and merge). A commit is generated in our target branch, but our CI tests are not being run against that commit. This in turn results in our deployment not being run, because it wait for a green CI before deploying.

runephilosof-abtion avatar Nov 05 '20 13:11 runephilosof-abtion

Yes, you need to configure that CI action to be triggered on workflow_run, I suppose. But this has nothing to do with the automerge action per se, so I cannot really help you here.

pascalgn avatar Nov 05 '20 18:11 pascalgn

Sorry to bother you again, but then I assume that you don't know of any examples to point us to, right?

Again, I know very little about GitHub actions as I only started to use them not too long ago, but from what I understand from the documentation of the repository dispatch event, the action should create the even via an API call (and only when the PR was merged) so other workflows can run on: repository_dispatch.

Using just on: workflow_run, it will be triggered on every automerge run, not only when the PR was merged. I'm not sure if there is any way to check if the result of the automerge workflow was a merge or not, but I think it would make much easier to configure this use case if the automerge action would just create a repository_dispatch event with an event_type like automerge-merged (it could also be a configuration variable for the action).

llucax avatar Nov 05 '20 19:11 llucax