# In case something goes horribly wrong, you can fall back to `image: ruby:latest` image: git-r3lab.uni.lu:4567/r3/docker/jekyll-lcsb:1.0 stages: - build - deploy - backup build the website: stage: build before_script: - gem install bundler -v2.0.2 - bundle install && bundle update jekyll-theme-lcsb-default && bundle update jekyll-theme-lcsb-frozen-components script: - bundle exec jekyll build -d build --config "_config.yml,_config_staticpages.yml" - 'echo $CI_COMMIT_SHA > build/version' artifacts: expire_in: 3 days paths: - build variables: JEKYLL_ENV: production ## Deploys the website to a separate VM Deploy to production: stage: deploy image: alpine:3.1 before_script: - 'which ssh-agent || ( apk add --update openssh )' - eval $(ssh-agent -s) - echo "$SSHPRIVKEY" | tr -d '\r' | ssh-add - > /dev/null - mkdir -p ~/.ssh && chmod 700 ~/.ssh - 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' - echo "$KNOWNHOSTS" > ~/.ssh/known_hosts - chmod 644 ~/.ssh/known_hosts script: # don't forget to create ~/web/latest folder manually in the initial configuration on the VM! - ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/web/r3lab_$CI_JOB_ID" - scp -P $SSHPORT -r build/* $SSHCONNECT:~/web/r3lab_$CI_JOB_ID # Make a symbolic link to newly copied files, then remove old tasks' files, and remove all broken symbolic links - ssh -p $SSHPORT $SSHCONNECT "cd ~/web/latest && ln -fs ../r3lab_$CI_JOB_ID/* . || true && cd ~/web/latest/web/ && ln -fs ../r3lab_$CI_JOB_ID/web/* . && cd ~/web && find . -type d -name 'r3lab*' -not -newermt '-1 minutes' -exec rm -rf {} + && find -L ~/web/latest -type l -delete && ln -fs ~/web/latest/link_to_minerva.html ~/web/latest/web/minerva-website.html || true" ## Backups Create the backup: stage: backup image: alpine:3.1 only: - schedules before_script: - 'which ssh-agent || ( apk add --update openssh )' - eval $(ssh-agent -s) - echo "$SSHPRIVKEY" | tr -d '\r' | ssh-add - > /dev/null - mkdir -p ~/.ssh && chmod 700 ~/.ssh - 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' - echo "$KNOWNHOSTS" > ~/.ssh/known_hosts - chmod 644 ~/.ssh/known_hosts script: - ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/web ~/backups/; cd /var/www/sites/r3lab.uni.lu; tar -zcvf ~/backups/backup_$(date +'%Y_%m_%d').tar.gz *" - ssh -p $SSHPORT $SSHCONNECT "cd ~/backups/; ls -tr | head -n -3 | xargs --no-run-if-empty rm "