diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e36c8f13ea4884760fb80f4e9e6f868278dfd385..b1db51857f9da8f74b19290ca21dc5c2003ad3dc 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -9,6 +9,7 @@ stages:
   - build_package
   - testing
   - create_docs
+  - deploy
 
 build_package:
   stage: build_package
@@ -34,6 +35,17 @@ create_docs:
     - poetry install
     - cd docs
     - poetry run sphinx-build -b html . ../public
+  artifacts:
+    paths:
+      - public
+
+deploy_docs:
+  stage: deploy
+  needs: [create_docs]
+  variables:
+    docs_upload_host: hosted-024-173.rz.uni-augsburg.de
+    docs_path_component: icartt
+  script:
     # Following lines are ssh-agent setup and key injection, to allow upload of docs
     - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
     - 'command -v rsync >/dev/null || ( apt-get update -y && apt-get install --no-install-recommends rsync -y )'
@@ -43,7 +55,7 @@ create_docs:
     - echo "$docs_ssh_key" | tr -d ' ' | base64 --decode | ssh-add -
     - mkdir -p ~/.ssh && chmod 700 ~/.ssh
     - ssh-keyscan ${docs_upload_host} > ~/.ssh/known_hosts
-    - rsync -ax ../public/ ${CI_PROJECT_NAME}-docs@${docs_upload_host}:/srv/docs/${docs_path_component}/public/$(poetry version -s)/
-  artifacts:
-    paths:
-      - public
+    - rsync -ax public/ ${CI_PROJECT_NAME}-docs@${docs_upload_host}:/srv/docs/${docs_path_component}/public/$(poetry version -s)/
+  rules:
+    # only deploy docs if the SSH key masked variable is set.
+    - if: $docs_ssh_key