-
Notifications
You must be signed in to change notification settings - Fork 3
/
bitbucket-pipelines.yml
41 lines (41 loc) · 2.43 KB
/
bitbucket-pipelines.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
image: php:7.1.3
pipelines:
default:
- step:
name: Build
script:
- apt-get update && apt-get install -y curl zip unzip
- curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
- unzip awscliv2.zip
- ./aws/install
- aws --version
- aws configure set aws_access_key_id "${AWS_KEY}"
- aws configure set aws_secret_access_key "${AWS_SECRET}"
- aws=$(aws ecr get-login-password --region ca-central-1)
- echo $aws | docker login --username AWS --password-stdin 754569496111.dkr.ecr.ca-central-1.amazonaws.com
- echo "aws=$aws" > ENVIRONMENT_VARIABLES.txt
# build the Docker image (this will use the Dockerfile in the root of the repo)
- docker build --memory=3072M -t lineblocs-internals .
- docker tag lineblocs-internals:latest 754569496111.dkr.ecr.ca-central-1.amazonaws.com/lineblocs-internals:latest
- docker push 754569496111.dkr.ecr.ca-central-1.amazonaws.com/lineblocs-internals:latest
artifacts: # define the artifacts to be passed to each future step
- ENVIRONMENT_VARIABLES.txt
services:
- docker
- step:
name: Deploy
deployment: production
image: atlassian/pipelines-kubectl
script:
# Download and install `doctl` so that we can refresh configs for k8s
- apk --no-cache add curl
- export $(cat ENVIRONMENT_VARIABLES.txt | xargs)
- echo $aws | docker login --username AWS --password-stdin 754569496111.dkr.ecr.ca-central-1.amazonaws.com
- curl -sL https://github.com/digitalocean/doctl/releases/download/v1.27.0/doctl-1.27.0-linux-amd64.tar.gz | tar -xzv
- mv ./doctl /usr/local/bin
- doctl -t $DOCTL_TOKEN k8s cluster kubeconfig show ${K8S_CLUSTER_NAME} > kubeconfig.yml
- kubectl --insecure-skip-tls-verify --kubeconfig=kubeconfig.yml --ignore-not-found=true delete secret lineblocs-regcred
- kubectl --insecure-skip-tls-verify --kubeconfig=kubeconfig.yml create secret generic lineblocs-regcred --from-file=.dockerconfigjson=/root/.docker/config.json --type=kubernetes.io/dockerconfigjson
- kubectl --insecure-skip-tls-verify --kubeconfig=kubeconfig.yml patch deployment lineblocs-internals -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"`date +'%s'`\"}}}}}"
services:
- docker