diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 22bcb57ed61dcdfafa76f6a028e493d388302eb9..c900f5fe962e93dfabc13486b58f2e80c43444e8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -20,8 +20,8 @@ variables:
   - 'time make -k -j$CPU_CORES TIMED=y 2>&1 | tee build-log.txt'
   - 'if fgrep Axiom build-log.txt >/dev/null; then exit 1; fi'
   - 'cat build-log.txt | egrep "[a-zA-Z0-9_/-]+ \((real|user): [0-9]" | tee build-time.txt'
-  # maybe generate and upload doc (has to be in this job as we need the .vo files)
-  - 'if test -n "$DOCDIR"; then build/coqdoc; fi'
+  # maybe generate and upload doc (has to be in this job as we need coq installed)
+  - 'if [[ -n "$DOCDIR" ]]; then build/coqdoc; fi'
   cache:
     key: "$CI_JOB_NAME"
     paths:
diff --git a/build/coqdoc b/build/coqdoc
index 10562a0c93df7fa3fb68e2a797756dc61268009b..31de37b84c5cf3be0f1c6d8d5799dd34063ce862 100755
--- a/build/coqdoc
+++ b/build/coqdoc
@@ -3,7 +3,7 @@
 # This reads the following environment variables:
 # - DOCDIR: The directory to upload the documentation to
 set -e
-echo "Publishing documentation from branch $CI_BUILD_REF to $DOCDIR"
+echo "Publishing documentation from branch $CI_COMMIT_REF_NAME to $DOCDIR"
 
 # We need a custom wrapper around SSH to use our settings, and ssh-agent for the key
 eval $(ssh-agent -s)
@@ -12,3 +12,9 @@ export GIT_SSH=$(readlink -e "$(dirname "$0")/ssh")
 
 # Enable tracing mode *after* we did the secret key stuff above
 set -x
+
+# Generate documentation
+make html
+
+# Upload documentation
+rsync -a -e "$GIT_SSH" html/ "$DOCDIR/"