Looking for a way to have a pipeline run only in MR creation and not in subsequent commits

Hi all,
I’m trying to find a way to trigger a pipeline only on the initial creation of an MR but not on subsequent commits to that MR
My scenario is:

  1. Engineer works on a feature branch and has the version in setup.py - 1.0.17
  2. Once he opens an MR, I want a pipeline to run and via the script bump the minor version to 1.1.0 and push the commit(that part works today)

I tried - if: $CI_PIPELINE_SOURCE == “merge_request_event” but my pipeline gets triggered on each of the subsequent commits as well.
For example, as part of the code review the engineer adds a fix, the pipeline is triggered on that commit as well and bumps the version to 1.2.0. This creates a commit with the bump, and that commit triggers the pipeline again and we have an infinite loop…

I’m looking for a way to distinguish the creation event (that doesn’t have a push?) from the rest of commits. This can be an env. variable or a complex condition.

Thanks for any help :slight_smile: