forked from opengovsg/FormSG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
123 lines (114 loc) · 3.73 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
os: linux
dist: xenial
services:
- xvfb
language: node_js
node_js: '14'
install: true # skip installation, perform in build stage.
notifications:
email:
recipients:
# Please change to your own email recipient if you are forking this
# repository.
on_success: always
on_failure: always
jobs:
include:
- stage: Build application
install: npm ci
cache:
- npm
- pip
before_script:
- export NODE_OPTIONS=--max-old-space-size=4096
script:
- set -e
- npm_config_mode=yes npx lockfile-lint --type npm --path package.json --validate-https --allowed-hosts npm
- npm run lint-ci
- npm run build
workspaces:
create:
name: build
paths: .
- stage: Deploy
services:
- docker
workspaces:
use: build
script: skip
before_deploy:
# Workaround to run before_deploy only once
- >
if ! [ "$TAG" ]; then
pip install --user awscli
# Put AWS in path
export PATH=$PATH:$HOME/.local/bin
# Login to AWS ECR, credentials defined in $AWS_ACCESS_KEY_ID and $AWS_SECRET_ACCESS_KEY
$(aws ecr get-login --no-include-email --region ap-southeast-1)
export TAG=travis-$TRAVIS_COMMIT-$TRAVIS_BUILD_NUMBER
docker build -f Dockerfile.production -t $REPO:$TAG .
docker tag $REPO:$TAG $REPO:$TRAVIS_BRANCH
docker push $REPO
# Add TAG to Dockerrun
sed -i -e "s/@TAG/$TAG/g" Dockerrun.aws.json
zip -r "$TAG.zip" .ebextensions Dockerrun.aws.json
fi
- export ELASTIC_BEANSTALK_LABEL="$TAG-$(env TZ=Asia/Singapore date "+%Y%m%d%H%M%S")"
deploy:
- provider: elasticbeanstalk
skip_cleanup: true
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
region: $AWS_REGION
app: $STAGING_APP_NAME
env: $UAT_DEPLOY_ENV
bucket: $STAGING_BUCKET_NAME
zip_file: '$TAG.zip'
on:
branch: $UAT_BRANCH
- provider: elasticbeanstalk
skip_cleanup: true
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
region: $AWS_REGION
app: $STAGING_APP_NAME
env: $STAGING_DEPLOY_ENV
bucket: $STAGING_BUCKET_NAME
zip_file: '$TAG.zip'
on:
branch: $STAGING_BRANCH
- provider: elasticbeanstalk
skip_cleanup: true
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
region: $AWS_REGION
app: $STAGING_APP_NAME
env: $STAGING_ALT_DEPLOY_ENV
bucket: $STAGING_BUCKET_NAME
zip_file: '$TAG.zip'
on:
branch: $STAGING_ALT_BRANCH
- provider: elasticbeanstalk
skip_cleanup: true
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
region: $AWS_REGION
app: $PROD_APP_NAME
env: $PROD_DEPLOY_ENV
bucket: $PROD_BUCKET_NAME
zip_file: '$TAG.zip'
on:
branch: $PROD_BRANCH
after_deploy:
- >
if [[ "$SENTRY_PROJECT" && "$SENTRY_AUTH_TOKEN" && "$SENTRY_ORG" && "$SENTRY_URL" ]]; then
curl -sL https://sentry.io/get-cli/ | bash
sentry-cli releases --org $SENTRY_ORG --project $SENTRY_PROJECT new "$TAG"
sentry-cli releases files "$TAG" upload-sourcemaps ./ --rewrite --ignore-file .sentryignore
sentry-cli releases finalize "$TAG"
fi
stages:
- Build application
- Tests
- Deploy