diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4a4de038155c56247f676aff40521bae618062cd..853b38297e642d57065ba192a90ced077367e39b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,8 +1,8 @@
 pages:
   stage: build
   needs: []
-  only:
-    - docs
+  rules:
+    - if: $CI_COMMIT_BRANCH == "docs"
   image: python:3.10
   script:
     - apt-get update && apt-get install -y python3-dev graphviz libgraphviz-dev