From 41bba68a990e180549d8f3382827f79f129fa3c7 Mon Sep 17 00:00:00 2001 From: Drew Short Date: Sat, 9 Feb 2019 10:19:01 -0600 Subject: [PATCH] Adding production build and deployment jobs --- .gitlab-ci.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..36f853c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,37 @@ +stages: + - build + - deploy + +build-website: + image: sothr.com/hugo:0.4.0 + stage: build + script: + - hugo --theme pure --destination /output --baseURL https://sothr.com + - TARGET=$PWD + - tar -czvf website.tgz -C /output/ . + only: + - master + tags: + - linux + artifacts: + paths: + - website.tgz + +deploy-website: + image: sothr.com/deploy:ubuntu + stage: deploy + variables: + TARGET_DIRECTORY: "/srv/www/sothr.com" + script: + - eval `ssh-agent -s` + - ssh-add <(echo "$SSH_DEPLOY_KEY") + - mkdir -p ~/.ssh + - ssh-keyscan -p $DEPLOY_PORT sothr.com >> ~/.ssh/known_hosts + - mkdir /tmp/deploy + - tar -xvf website.tgz -C /tmp/deploy + - rsync -avz --delete-delay -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p $DEPLOY_PORT" --progress /tmp/deploy/* $DEPLOY_USER@$DEPLOY_HOST:$TARGET_DIRECTORY + only: + - master + tags: + - docker + environment: production