From dbaae1045d72238c87f082f05b05d567ac11775f Mon Sep 17 00:00:00 2001 From: Christoph Knote <christoph.knote@med.uni-augsburg.de> Date: Thu, 28 Apr 2022 14:27:46 +0200 Subject: [PATCH] Conditional docs deploy job --- .gitlab-ci.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e36c8f1..b1db518 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 -- GitLab