-
Notifications
You must be signed in to change notification settings - Fork 3
/
k8-buildspec.yml
29 lines (29 loc) · 1.09 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
---
version: 0.2
phases:
install:
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-cronjob.yaml
- echo "${CODEBUILD_WEBHOOK_HEAD_REF}"
- echo "${BRANCH}"
- echo $REPOSITORY_URI
- $(aws ecr get-login --no-include-email)
build:
commands:
- |
if expr "${BRANCH}" : ".*master" >/dev/null || expr "${BRANCH}" : ".*dev" >/dev/null; then
docker build --tag $REPOSITORY_URI:$TAG .
fi
post_build:
commands:
- |
if expr "${BRANCH}" : ".*master" >/dev/null || expr "${BRANCH}" : ".*dev" >/dev/null; then
docker push $REPOSITORY_URI:$TAG
aws eks update-kubeconfig --name $EKS_CLUSTER_NAME --region us-east-1 --role-arn $EKS_KUBECTL_ROLE_ARN
kubectl set image cronjob/$CRON_JOB_NAME $CRON_JOB_NAME=$REPOSITORY_URI:$TAG -n reciter
fi