diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 472e11630cec322193921d3613417019af5696c3..193bc8ffd3cd1d22bf99026a755b60706dff58a2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -35,7 +35,7 @@ job_build_artifact:
 job_publish_artifact:
   stage: publish
   rules: # Conditions under which this job should run
-    - if:  $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"  # Run this job only for merge request event into main.
+    - if:  $CI_PIPELINE_SOURCE == "push" && $CI_MERGE_COMMIT_REF_NAME =~ /main/  # Run this job only for merge request event into main.
       when: always
   image: curlimages/curl:latest # Custom image with curl
   tags: