diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index aeb0c11863a4cd1ba52396dbbbad441545366390..67415c1b3a7da52e3179bec8463cd69ac3c667aa 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -289,3 +289,27 @@ 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: []
+  image: $CI_REGISTRY/caosdb/src/caosdb-pylib/testenv:latest
+  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