diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6ebcb262f673fde8430f02c922cfec410aad7e6c..c62f9101dea68fb9352dbdac4a33071489ef9cd1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -47,8 +47,9 @@ staging_deploy:
   extends: .deploy
   variables:
     ENVIRONMENT_ID: 'staging'
-  only:
-    - main
+  rules:
+    - if: $CI_COMMIT_BRANCH == "main"
+      when: on_success
   resource_group: staging
 
 production_deploy:
@@ -57,6 +58,7 @@ production_deploy:
   needs: ["staging_deploy"]
   variables:
     ENVIRONMENT_ID: 'production'
-  only:
-    - main
+  rules:
+    - if: $CI_COMMIT_BRANCH == "main"
+      when: on_success
   resource_group: production