diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3e08eb521f85944f8ba13321d7244da257022aa3..ee94ac7247e5291ceeda2a82ab987055bd0315b2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -21,8 +21,11 @@ build-page:
     - |
       if [[ "$CI_COMMIT_BRANCH" == "main" ]]; then
         JEKYLL_ENV=production bundle exec jekyll build --config _config_draft.yml --destination public
-      if [[ "$CI_COMMIT_BRANCH" == "publish" ]]; then
+      elif [[ "$CI_COMMIT_BRANCH" == "publish" ]]; then
         JEKYLL_ENV=production bundle exec jekyll build --config _config.yml --destination public
+      else
+        echo "Branch is neither main nor publish. Skipping build."
+        exit 1
       fi
     - echo "Listing contents of public directory:"
     - ls -laR public