version: 2 jobs: build-package: working_directory: /tmp/repo docker: - image: node:6.17.1-jessie steps: - checkout - restore_cache: key: node-dependencies-{{ checksum "package.json" }} - run: npm install - save_cache: paths: - node_modules key: node-dependencies-{{ checksum "package.json" }} - run: name: Build Artifact command: | mkdir ./artifact DEPLOYABLE="${CIRCLE_PROJECT_REPONAME}-${CIRCLE_SHA1}.tar.gz" rsync -avz --exclude 'artifact' * artifact/ cp -rf * ./artifact/ pushd ./artifact echo "Taring ${DEPLOYABLE}" tar -zcvf $DEPLOYABLE * popd - persist_to_workspace: root: /tmp/repo paths: - artifact upload-package: environment: ENVIRONMENT: "dev" REGION: "eu-central-1" working_directory: /tmp/repo docker: - image: monosolutions/awscli:latest steps: - attach_workspace: at: /tmp/repo - run: name: Upload Artifact Dev command: | aws configure set aws_access_key_id "${AWS_DEV_ACCESS_KEY}" aws configure set aws_secret_access_key "${AWS_DEV_SECRET_KEY}" BUCKET="mono-deployment-${ENVIRONMENT}" DEPLOYABLE="${CIRCLE_PROJECT_REPONAME}-${CIRCLE_SHA1}.tar.gz" { aws s3api create-bucket --bucket "${BUCKET}" } || { echo "Bucket is here" } aws s3 cp "/tmp/repo/artifact/${DEPLOYABLE}" "s3://${BUCKET}/tileserver-gl/${DEPLOYABLE}" deploy-to-dev: docker: - image: monosolutions/terraform:1.0.4 working_directory: /tmp/repo environment: REGION: "eu-central-1" ENVIRONMENT: "dev" steps: - checkout - run: name: Configure deployment command: | aws configure set aws_access_key_id "${AWS_DEV_ACCESS_KEY}" aws configure set aws_secret_access_key "${AWS_DEV_SECRET_KEY}" aws configure set region "${REGION}" wget https://github.com/gruntwork-io/terragrunt/releases/download/v0.14.10/terragrunt_linux_amd64 -O terragrunt chmod a+x terragrunt mv terragrunt /bin/ sed -i -e "s/repo_version =/repo_version = \"${CIRCLE_SHA1}\"/g" \ "${REGION}/${ENVIRONMENT}/tileserver/terraform.tfvars" - run: name: Deploy tileserver to fra dev command: | cd /tmp/repo/deployment/eu-central-1/dev/tileserver && terragrunt apply --terragrunt-non-interactive -auto-approve workflows: version: 2 deploy: jobs: - build-package: filters: branches: only: - master - MODE-11365 - upload-package: requires: - build-package - deploy-to-dev: requires: - upload-package