-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcircle.yml
114 lines (93 loc) · 2.57 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
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
version: 2
vars:
defaults_node: &defaults_node
docker:
- image: circleci/node:8-browsers
environment:
JOBS: 2
defaults_python: &defaults_python
docker:
- image: circleci/python
environment:
JOBS: 2
install_awscli: &install_awscli
run:
name: Install awscli
command: sudo pip install awscli
node_key: &node_key
key: node-deps-v1-{{ arch }}-{{ checksum "yarn.lock" }}-{{ checksum "circle.yml" }}
restore_node: &restore_node
restore_cache:
<<: *node_key
save_bundle_to_workspace: &save_bundle_to_workspace
persist_to_workspace:
root: dist
paths:
- bundle.js.gz
attach_workspace_bundle: &attach_workspace_bundle
attach_workspace:
at: /tmp/dist/
jobs:
build:
<<: *defaults_node
steps:
- checkout
- <<: *restore_node
- run:
name: Node dependencies
command: |
if [ ! -d node_modules ]; then
yarn --pure-lockfile
fi
- save_cache:
<<: *node_key
paths:
- node_modules
- run:
name: Build bundle
command: npx webpack -p
- <<: *save_bundle_to_workspace
deploy_demo:
<<: *defaults_python
environment:
ENV: demo
steps:
- checkout
- <<: *attach_workspace_bundle
- <<: *install_awscli
- run:
name: Deploy to demo
command: aws s3 cp /tmp/dist/bundle.js.gz s3://${DEMO_AWS_BUCKET}/dfp-ad-templates/bundle.js --region ${DEMO_AWS_REGION} --acl public-read --cache-control max-age=0 --content-type "application/javascript" --content-encoding "gzip"
deploy_production:
<<: *defaults_python
environment:
ENV: prod
steps:
- checkout
- <<: *attach_workspace_bundle
- <<: *install_awscli
- run:
name: Deploy to production
command: aws s3 cp /tmp/dist/bundle.js.gz s3://${PROD_AWS_BUCKET}/dfp-ad-templates/bundle.js --region ${PROD_AWS_REGION} --acl public-read --cache-control max-age=0 --content-type "application/javascript" --content-encoding "gzip"
workflows:
version: 2
install-test-deploy:
jobs:
- build:
filters:
tags:
only: /.*/
- deploy_production:
requires:
- build
filters:
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+/
branches:
ignore: /.*/
- deploy_demo:
requires:
- build
filters:
branches:
only: master