pipelines-as-code icon indicating copy to clipboard operation
pipelines-as-code copied to clipboard

Trigger PipelineRun on opening/closing PR

Open LvanLeeuwen opened this issue 2 years ago • 4 comments

Currently PipelinRuns targeting the pull_request event are triggered every time a commit occurs on a pull_request. However, we'd like to be able to trigger a PipelineRun only when a PR is opened or closed and no longer on the commits to the pull request. One way to achieve this behavior is to use GitHub workflows to start the PipelineRun by sending a CURL request (https://pipelinesascode.com/docs/guide/incoming_webhook/). Unfortunately, we can't set the branch name to any name, since the Repository resource doesn't allow wildcards for the incoming target branch name and constantly updating the Repository resource is not favorable.

Would it be possible to either support wildcards for the incoming target branch name in the Repository resource, or to extend the events or cel expressions to include events for opening/closing PRs?

LvanLeeuwen avatar Aug 30 '23 07:08 LvanLeeuwen

both request are valid!

you can only create a pull request when you have commit in there tho? or did you mean "reopen" a PR ?

chmouel avatar Aug 30 '23 07:08 chmouel

No, I meant create a pull request when there is at least one commit in there

LvanLeeuwen avatar Aug 30 '23 07:08 LvanLeeuwen

ah gotcha, that's an interesting use case... would you mind explaining your workflow on how do you do use this? i will be happy to jump on a call quickly with @koustavsaha if you think it's better explained over the phone

chmouel avatar Aug 30 '23 12:08 chmouel

Our workflow is that we want to be able to fire certain PipelineRuns manually, without it being part of an event. These could be things such as more extensive tests that require more resources.

A way to do this is to trigger the webhook using GitHub actions.

But we're unable to have wildcards in the Repository CRD:

  incoming:
    - targets:
        - main
        - feature/* <<<
      type: webhook-url

Is there something that already caters for this use case?

zeida-of avatar Sep 25 '23 09:09 zeida-of