-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuildspec.yml
38 lines (35 loc) · 1.78 KB
/
buildspec.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
version: 0.2
env:
variables:
DOCKER_REGISTRY: 320464205386.dkr.ecr.us-west-2.amazonaws.com
phases:
install:
commands:
- apt update && apt install -y apt-transport-https curl
- curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
- echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list
- apt update && apt install -y kubectl
- curl -O https://get.helm.sh/helm-v2.11.0-linux-amd64.tar.gz
- tar zxf helm-v2.11.0-linux-amd64.tar.gz
- mv linux-amd64/helm /usr/local/bin/
- curl -O https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-07-26/bin/linux/amd64/aws-iam-authenticator
- chmod +x aws-iam-authenticator
- mv aws-iam-authenticator /usr/local/bin/
- apt update && apt install -y python3-pip
- pip3 install awscli
- echo "Configuring kubectl"
pre_build:
commands:
- export COMMIT_SHA=$CODEBUILD_RESOLVED_SOURCE_VERSION
- export DEPLOY_ENV=$(echo $CODEBUILD_WEBHOOK_TRIGGER | sed -e 's/tag\/.*-\(.*\)/\1/' | sed -e 's/branch\/master/dev/')
- export MASTER=$(if [ "$CODEBUILD_WEBHOOK_TRIGGER" = "branch/master" ]; then echo 1; fi)
- echo "running for ${COMMIT_SHA} in ${DEPLOY_ENV}"
- aws eks update-kubeconfig --name $CLUSTER_NAME
- aws ecr get-login --region us-west-2 --no-include-email | bash
build:
commands:
- echo "nothing to build here, moving on"
post_build:
commands:
- echo "Environment is ${DEPLOY_ENV}"
- '[ -n "$MASTER" ] && cd external/elastic/ && helm template -f k8s/values.yaml -f k8s/values/$DEPLOY_ENV.yaml --set docker_registry=$DOCKER_REGISTRY,namespace=dinopark-$DEPLOY_ENV,rev=$COMMIT_SHA k8s/ | kubectl --token $DEPLOY_TOKEN apply -f - && cd ../..'