107 lines
3.3 KiB
YAML
107 lines
3.3 KiB
YAML
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"
|
|
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/
|
|
- 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 --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
|