-
Notifications
You must be signed in to change notification settings - Fork 5
/
k8-buildspec.yml
40 lines (40 loc) · 1.95 KB
/
k8-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
---
version: 0.2
phases:
install:
runtime-versions:
java: openjdk11
commands:
- kubectl version --short --client
pre_build:
commands:
- TAG="${BRANCH}-$CODEBUILD_BUILD_NUMBER.$(date +%Y-%m-%d.%H.%M.%S).$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)"
- echo $TAG
- sed -i.bak -e 's@CONTAINER_IMAGE@'"$REPOSITORY_URI:$TAG"'@' kubernetes/k8-deployment.yaml
- echo "${CODEBUILD_WEBHOOK_HEAD_REF}"
- echo "${BRANCH}"
- |
if expr "${BRANCH}" : ".*dev" >/dev/null; then
sed -i.bak -e 's@NAMESPACE@'"reciter"'@' -e 's@ENVCONFIG@'"env-config-dev"'@' -e 's@APPNAME@'"reciter-scopus-dev"'@' -e 's@HPANAME@'"hpa-reciter-scopus-dev"'@' -e 's@ENVIRONMENT_LABEL@'"dev"'@' kubernetes/k8-deployment.yaml;
fi
- |
if expr "${BRANCH}" : ".*master" >/dev/null; then
sed -i.bak -e 's@NAMESPACE@'"reciter"'@' -e 's@ENVCONFIG@'"env-config-prod"'@' -e 's@APPNAME@'"reciter-scopus-prod"'@' -e 's@HPANAME@'"hpa-reciter-scopus-prod"'@' -e 's@ENVIRONMENT_LABEL@'"prod"'@' kubernetes/k8-deployment.yaml;
fi
- $(aws ecr get-login --no-include-email)
- cat ./kubernetes/k8-deployment.yaml
build:
commands:
- mvn clean install -Dmaven.test.skip=true
- |
if expr "${BRANCH}" : ".*master" >/dev/null || expr "${BRANCH}" : ".*dev" >/dev/null; then
docker build --tag $REPOSITORY_URI:$TAG .
docker push $REPOSITORY_URI:$TAG
aws eks update-kubeconfig --name $EKS_CLUSTER_NAME --region us-east-1 --role-arn $EKS_KUBECTL_ROLE_ARN
fi
if expr "${BRANCH}" : ".*master" >/dev/null; then
kubectl set image deployment/reciter-scopus-prod reciter-scopus=$REPOSITORY_URI:$TAG -n $EKS_CLUSTER_NAME
fi
if expr "${BRANCH}" : ".*dev" >/dev/null; then
kubectl set image deployment/reciter-scopus-dev reciter-scopus=$REPOSITORY_URI:$TAG -n $EKS_CLUSTER_NAME
fi