-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.travis.yml
108 lines (97 loc) · 3.93 KB
/
.travis.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
dist: xenial
language: ruby
services:
- docker
env:
global:
- LOCAL_BIN=${HOME}/.local/bin # For downloaded tools like terraform and awscli
# Retrieve commit tag values for each micro-service folder to be used in tagging and deploying docker images.
# Dependency folders are included as well and must be maintained
- REA_APP_TAG=$(git log --pretty=format:rc-%h -n 1 -- app)
- TESTBOX_TAG=$(git log --pretty=format:rc-%h -n 1 -- app)
before_install:
- mkdir -p ${LOCAL_BIN}
- export PATH=${PATH}:${LOCAL_BIN} # Put aws in the path
- git config --global url.git@github.com:.insteadOf https://github.com/
- make common-deps # install dependencies from Makefile in the root
script:
- set -e # Stop script immediately on error
- cd $SERVICE_DIR
- export AWS_PROFILE=${TARGET_AWS_PROFILE}
- make check-image-exists && travis_terminate 0 || echo "Image doesn't exist, continue with build process";
- make publish # Publish will do the build
# This governs the order of stage-execution
stages:
- name: build
- name: deployment
jobs:
include:
- stage: build
name: "✍️ REA WEB SERVER: Build, test and publish the image"
env:
- SERVICE_DIR=app
- TARGET_AWS_PROFILE=AWS_STEVE
- COMMIT_HASH=${REA_APP_TAG}
if: (branch = tag AND tag =~ /v\d+.\d+(.\d+)?/) OR (branch != tag)
- stage: build
name: "✍️ TESTBOX: Build, test and publish the image"
env:
- SERVICE_DIR=testbox
- TARGET_AWS_PROFILE=AWS_STEVE
- COMMIT_HASH=${TESTBOX_TAG}
if: (branch = tag AND tag =~ /v\d+.\d+(.\d+)?/) OR (branch != tag)
# Deploy the infrastructure, use for branch
- stage: deployment
name: "🏖️ Branch manual deploy to AWS: Apply changes to kubernetes infrastructure and update container images"
env:
- SERVICE_DIR=infra
- REGION=ap-southeast-2
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
script:
- set -e # Stop script immediately on error
- cd $SERVICE_DIR
- make depend
- make deploy
if: commit_message ="deploy-to-aws" AND type != pull_request
# Deploy the infrastructure, use for master
- stage: deployment
name: "🏖️ Master deploy to AWS: Apply changes to kubernetes infrastructure and update container images"
env:
- SERVICE_DIR=infra
- REGION=ap-southeast-2
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
script:
- set -e # Stop script immediately on error
- cd $SERVICE_DIR
- make depend
- make deploy
if: branch = master AND type != pull_request AND commit_message !="deploy-to-aws" AND commit_message !="destroy-to-aws"
# Deploy the infrastructure, use for new release
- stage: deployment
name: "🏖️ New release deploy to AWS: Apply changes to kubernetes infrastructure and update container images"
env:
- SERVICE_DIR=infra
- REGION=ap-southeast-2
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
script:
- set -e # Stop script immediately on error
- cd $SERVICE_DIR
- make depend
- make deploy
if: branch = tag AND type != pull_request AND tag =~ /v\d+.\d+(.\d+)?/ AND commit_message !="deploy-to-aws" AND commit_message !="destroy-to-aws"
- stage: deployment
name: "♨️ Branch manual destroy AWS: Destroy changes in aws"
env:
- SERVICE_DIR=infra
- REGION=ap-southeast-2
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
script:
- set -e # Stop script immediately on error
- cd $SERVICE_DIR
- make depend
- make destroy
if: commit_message ="destroy-to-aws" AND type != pull_request