tileserver-gl/.circleci/config.yml
2019-04-25 12:21:02 +02:00

112 lines
3.6 KiB
YAML

version: 2
jobs:
build-package:
working_directory: /usr/src/app
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"
cp -rf configuration \
node_modules \
src \
run.sh \
package.json \
map_files \
public \
docs \
publish.js \
./artifact/
pushd ./artifact
echo "Taring ${DEPLOYABLE}"
tar -zcvf $DEPLOYABLE *
popd
cp -rf ./deployment ./artifact/
mkdir -p /tmp/repo && mv artifact /tmp/repo/
- 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}"
- persist_to_workspace:
root: /tmp/repo
paths:
- artifact
deploy-to-dev:
docker:
- image: monosolutions/terraform:1.0.4
working_directory: /tmp/repo/artifact/deployment
environment:
REGION: "eu-central-1"
ENVIRONMENT: "dev"
steps:
- attach_workspace:
at: /tmp/repo
- 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/artifact/deployment/eu-central-1/dev/tileserver && \
terragrunt apply \
-var="aws_access_key=$AWS_DEV_ACCESS_KEY" \
-var="aws_secret_key=$AWS_DEV_SECRET_KEY" \
-var="repo_version=$CIRCLE_SHA1" \
--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