-
Notifications
You must be signed in to change notification settings - Fork 32
/
buildspec.yml
41 lines (40 loc) · 1.81 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
38
39
40
41
version: 0.2
phases:
install:
runtime-versions:
docker: 18
nodejs: 12
commands:
- '. ci/install_deps.sh'
pre_build:
commands:
- export COMMIT_SHA=$CODEBUILD_RESOLVED_SOURCE_VERSION
- export CODEBUILD_WEBHOOK_TRIGGER=${CODEBUILD_WEBHOOK_TRIGGER:-branch/master}
- export DEPLOY_ENV=$(echo $CODEBUILD_WEBHOOK_TRIGGER | sed -e 's/tag\/.*-\(.*\)/\1/' | sed -e 's/branch\/master/dev/')
- export PR=$(if case $CODEBUILD_WEBHOOK_TRIGGER in pr/*) ;; *) false;; esac; then echo 1; fi)
- export MASTER=$(if [ "$CODEBUILD_WEBHOOK_TRIGGER" = "branch/master" ]; then echo 1; fi)
- echo "running for ${COMMIT_SHA} in ${DEPLOY_ENV}"
- aws ecr get-login --region us-west-2 --no-include-email | bash
- echo "Logging Into Docker Hub"
- echo $DOCKERHUB_PASSWORD | docker login --username $DOCKERHUB_USERNAME --password-stdin
build:
commands:
- if [ "$PR" = 1 ]; then myke docker; fi
- if [ "$MASTER" = 1 ]; then myke docker --rev=$COMMIT_SHA push-image --rev=$COMMIT_SHA; fi
post_build:
commands:
- if [ "$CODEBUILD_BUILD_SUCCEEDING" = 0 ] ; then exit 1 ; fi
- |
if [ "$PR" = "" ] && { [ "$DEPLOY_ENV" = "dev" ] || [ "$DEPLOY_ENV" = "test" ] ;}; then
echo "Deploying to dev and test envirnoments..."
aws eks update-kubeconfig --name kubernetes-stage-us-west-2
myke deploy --deploy_env=dev --rev=$COMMIT_SHA
aws eks update-kubeconfig --name kubernetes-prod-us-west-2
myke deploy --deploy_env=test --rev=$COMMIT_SHA
fi
- |
if [ "$PR" = "" ] && [ "$DEPLOY_ENV" = "prod" ]; then
echo "Deploying to prod envirnoment..."
aws eks update-kubeconfig --name kubernetes-prod-us-west-2
myke deploy --deploy_env=prod --rev=$COMMIT_SHA
fi