diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d8ce86dd27a21dfedacb552de908cd55748d5dcb..b058c4796458705bc69aba58ec3a1704610c4850 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -170,13 +170,24 @@ build_emsdk_image:
   needs:
     - build_docker_dind_image
   rules:
-    - if: $CI_COMMIT_BRANCH
+    - if: $CI_COMMIT_BRANCH == "main" # for branch main run if there were changes on the branch
       exists:
         - Dockerfile.emscripten
       changes:
+        paths:
+          - Dockerfile.emscripten
+          - scripts/bash/emscripten/*
+          - scripts/bash/emscripten/**/*
+    - if: $CI_COMMIT_BRANCH !~ /^main$/ # for other branches compare to develop and run if there are diffrences
+      exists:
         - Dockerfile.emscripten
-        - scripts/bash/emscripten/*
-        - scripts/bash/emscripten/**/*
+      changes:
+        paths:
+          - Dockerfile.emscripten
+          - scripts/bash/emscripten/*
+          - scripts/bash/emscripten/**/*
+        compare_to: 'refs/heads/develop'
+
 
 example_docker_image_builder_job:
   extends: .docker_image_builder_job_template