diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index bfac6b0012cb067657567381752a600736e7d788..42810175de0ca747bd25f7d5388af1fc7d88770d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -277,3 +277,26 @@ style:
   script:
       - autopep8 -r --diff --exit-code .
   allow_failure: true
+
+# Build the sphinx documentation and make it ready for deployment by Gitlab Pages
+# Special job for serving a static website. See https://docs.gitlab.com/ee/ci/yaml/README.html#pages
+# Based on: https://gitlab.indiscale.com/caosdb/src/caosdb-pylib/-/ci/editor?branch_name=main
+pages_prepare: &pages_prepare
+  tags: [ cached-dind ]
+  stage: deploy
+  needs: []
+  only:
+    refs:
+      - /^release-.*$/i
+  script:
+    - echo "Deploying documentation"
+    - make doc
+    - cp -r build/doc/html public
+  artifacts:
+    paths:
+      - public
+pages:
+  <<: *pages_prepare
+  only:
+    refs:
+      - main