From 3a8a73368a127bb8b5b2e612d7cf4ba4986dad11 Mon Sep 17 00:00:00 2001 From: Anton Akhmerov <anton.akhmerov@gmail.com> Date: Tue, 25 Dec 2018 00:29:00 +0100 Subject: [PATCH] setup publishing from all branches --- .gitlab-ci.yml | 61 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6c10a7aa..60efabae 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,25 @@ image: quantumtinkerer/research -build and upload the contents: +stages: + - build + - deploy + +build lectures: + stage: build + before_script: + - pip install -U mkdocs mkdocs-material python-markdown-math notedown + script: + - python execute.py + - mkdocs build + artifacts: + paths: + - site + expire_in: 1 week + +.prepare_deploy: &prepare_deploy + stage: deploy + only: + - branches@solidstate/lectures before_script: ## Install ssh-agent if not already installed, it is required by Docker. ## (change apt-get to yum if you use an RPM-based image) @@ -20,12 +39,40 @@ build and upload the contents: - chmod 700 ~/.ssh - ssh-keyscan tnw-tn1.tudelft.net >> ~/.ssh/known_hosts - chmod 644 ~/.ssh/known_hosts - - pip install -U mkdocs mkdocs-material python-markdown-math notedown - script: - # Compile lectures - - python execute.py - - mkdocs build - - "rsync -rv site/* solidstate@tnw-tn1.tudelft.net:" + - "rsync -rv site/* solidstate@tnw-tn1.tudelft.net:$DEPLOY_PATH" + +deploy delft version: + <<: *prepare_deploy only: - local@solidstate/lectures + variables: + DEPLOY_PATH: "" + environment: + name: $CI_COMMIT_REF_NAME + url: "https://solidstate.quantumtinkerer.tudelft.nl/" + +deploy test version: + <<: *prepare_deploy + except: + - local@solidstate/lectures + variables: + DEPLOY_PATH: "test_builds/$CI_COMMIT_REF_NAME" + environment: + name: $CI_COMMIT_REF_NAME + url: "https://solidstate.quantumtinkerer.tudelft.nl/test_builds/$CI_COMMIT_REF_NAME" + on_stop: undeploy test version + +undeploy test version: + <<: *prepare_deploy + except: + - local@solidstate/lectures + when: manual + variables: + DEPLOY_PATH: "test_builds/$CI_COMMIT_REF_NAME" + script: + - mkdir empty/ + - "rsync -rlv --delete empty/ solidstate@tnw-tn1.tudelft.net:$DEPLOY_PATH" + environment: + name: $CI_COMMIT_REF_NAME + action: stop -- GitLab