diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3defaf2ebd6ef9290ecd933811ffb8b58e92a0d8..c5b43d5dda3965968577b7560d5df06d23740ab7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,8 +1,8 @@
 image: python:3.8-buster
 
 stages:
-  - bundle
   - test
+  - bundle
   - deploy
   - release
 
@@ -22,25 +22,6 @@ cache:
   paths:
     - ./node_modules
 
-bundle_and_test:
-  stage: bundle
-  before_script:
-    - apt-get --quiet update
-    - apt-get --quiet --yes install nodejs
-    - npm install -g @apidevtools/swagger-cli
-
-  script:
-    - mkdir public
-    - swagger-cli bundle -t json $API_ROOT_FILE > $BUNDLED_JSON_FILE
-    - swagger-cli validate $BUNDLED_JSON_FILE
-
-  artifacts:
-    paths:
-      - public
-    expire_in: 2 days
-  only:
-    - $CI_DEFAULT_BRANCH
-
 check_style:
   stage: test
   before_script:
@@ -57,7 +38,25 @@ check_style:
 #     - pip3 install tox
 #     - tox
 
-pages:
+bundle_and_test:
+  stage: bundle
+  before_script:
+    - apt-get --quiet update
+    - apt-get --quiet --yes install nodejs
+    - npm install -g @apidevtools/swagger-cli
+  script:
+    - mkdir public
+    - swagger-cli bundle -t json $API_ROOT_FILE > $BUNDLED_JSON_FILE
+    - swagger-cli validate $BUNDLED_JSON_FILE
+  artifacts:
+    paths:
+      - public
+    expire_in: 2 days
+  rules:
+    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+      when: always
+
+deploy_spec:
   stage: deploy
   before_script:
     - apt-get --quiet update
@@ -73,8 +72,9 @@ pages:
     paths:
       - public
     expire_in: 2 days
-  only:
-    - $CI_DEFAULT_BRANCH
+  rules:
+    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+      when: always
 
 docker-push:
   # Use the official docker image.