-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcircle.yml
80 lines (73 loc) · 1.97 KB
/
circle.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
version: 2
jobs:
build:
docker:
- image: circleci/node:8.7
steps:
- checkout
- restore_cache:
key: node-deps-{{ checksum "yarn.lock" }}
- run:
name: Install node dependencies
command: yarn --pure-lockfile
- save_cache:
key: node-deps-{{ checksum "yarn.lock" }}
paths:
- ./node_modules
test:
docker:
- image: circleci/node:8.7-browsers
steps:
- checkout
- restore_cache:
key: node-deps-{{ checksum "yarn.lock" }}
- run:
name: Test
command: yarn test
deploy:
docker:
- image: circleci/node:8.7
steps:
- checkout
- restore_cache:
key: node-deps-{{ checksum "yarn.lock" }}
- run:
name: Install aws cli
command: sudo apt-get -y -qq install awscli
- run:
name: Deploy to S3
command: |
if [[ "${CIRCLE_BRANCH}" == "master" ]]; then
env | sed -n 's/^DEMO_//p' > .env
export AWS_BUCKET=$DEMO_AWS_BUCKET
export AWS_PREFIX=$DEMO_AWS_PREFIX
elif grep -q "v[0-9]\+\.[0-9]\+\.[0-9]\+" <<< "$CIRCLE_TAG"; then
env | sed -n 's/^PROD_//p' > .env
export AWS_BUCKET=$PROD_AWS_BUCKET
export AWS_PREFIX=$PROD_AWS_PREFIX
fi
yarn build
aws s3 sync ./build/ s3://"$AWS_BUCKET"/"$AWS_PREFIX"
aws s3 cp ./build/index.html s3://"$AWS_BUCKET"/"$AWS_PREFIX"/ --cache-control "max-age=0, no-cache"
workflows:
version: 2
buld-test-deploy:
jobs:
- build:
filters:
tags:
only: /.*/
- test:
filters:
tags:
only: /.*/
requires:
- build
- deploy:
requires:
- test
filters:
tags:
only: /^v[0-9]\.[0-9]\.[0-9]+/
branches:
only: master