From e63ea8125379ff7f069fcadafde5506811158ef6 Mon Sep 17 00:00:00 2001 From: pwalter <pwalter@ebi.ac.uk> Date: Thu, 26 Oct 2017 17:02:32 +0100 Subject: [PATCH] add aws deployment --- .gitlab-ci.yml | 23 +++++++++++++++++++++++ bin/deploy-aws | 25 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 bin/deploy-aws diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b2baa45b..007dada2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,14 +3,18 @@ image: netroby/alpine-rsync #project specific variables can be defines here, or overridden project settings variables: SERVER_DEV: ebi-cli.ebi.ac.uk + S3_BUCKET_DEV: dev.ebi.emblstatic.net SCRIPT_DEV: ~/bin/update-ebi-framework DEV_URL: http://wwwdev.ebi.ac.uk/web_guidelines/EBI-Framework SERVER_PROD: ebi-cli.ebi.ac.uk + S3_BUCKET_PROD: origin.ebi.emblstatic.net SCRIPT_PROD: ~/bin/update-ebi-framework-prod PROD_URL: http://www.ebi.ac.uk/web_guidelines/EBI-Framework # do not define here, put in project variables SSH_USER: username SSH_KEY: secret-key + AWS_KEY: key + AWS_SECRET: secret-key #setup ssh keys .deploy_setup: &deploy_setup @@ -44,3 +48,22 @@ deploy_live: name: live url: ${LIVE_URL} +deploy_aws_dev: + image: ebiwd/alpine-ssh + stage: deploy + before_script: + - add-aws-key ${AWS_KEY} ${AWS_SECRET} + script: + - bin/deploy-aws + only: + - branches + +deploy_aws_live: + image: ebiwd/alpine-ssh + stage: deploy + before_script: + - add-aws-key ${AWS_KEY} ${AWS_SECRET} + script: + - bin/deploy-aws prod + only: + - tags diff --git a/bin/deploy-aws b/bin/deploy-aws new file mode 100755 index 00000000..41260fb9 --- /dev/null +++ b/bin/deploy-aws @@ -0,0 +1,25 @@ +#!/bin/bash + +# abort on error +set -e; +# abort on undefined variable +set -u; + +# get current branch from git info +PROJECT=${CI_PROJECT_NAME}; +BRANCH=${CI_COMMIT_REF_NAME}; + +# set project base +DEPLOY_PATH="web_guidelines/${PROJECT}/${BRANCH}"; + +if [ "${1:-''}" = "prod" ]; then + S3_BUCKET=${S3_BUCKET_PROD}; +else + S3_BUCKET=${S3_BUCKET_DEV}; +fi; + +# push to AWS (exclude bin and .git) +aws s3 sync . s3://${S3_BUCKET}/${DEPLOY_PATH} \ + --exclude ".git*" \ + --exclude "bin/*" \ + ; -- GitLab