Gitlab CI only run on Merge Request
To configure pipelines for merge requests,
add the only: [merge_requests] parameter to
the jobs that you want to run only for merge requests.
Then, when developers create or update merge requests,
a pipeline runs every time a commit is pushed to GitLab.
enable_merge:
only: [merge_requests]
script:
- echo true
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "push"
job1:
script:
- echo "This job runs in merge request and also after merge to main branch"
# mwps BRANCHNAME
alias mwps='git push -u origin -o merge_request.create -o merge_request.target=main -o merge_request.merge_when_pipeline_succeeds'