-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconfig.yml
182 lines (152 loc) · 6.62 KB
/
config.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2.1
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:8.11.4-browsers
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
name : Restore NPM Cache
key: npm-cache-{{ checksum "package.json" }}
- run:
name: Download and install meteor
command: curl -k https://install.meteor.com | /bin/sh
#- run:
# name: Create Settings File
# command: echo $METEOR_SETTINGS > settings.json
- run:
name: Install npm dependencies
command: meteor npm install
- save_cache:
name: Save NPM Cache
key: npm-cache-{{ checksum "package.json" }}
paths:
- 'node_modules'
- run:
name: Run Linting
command: meteor npm run lint --silent
- save_cache:
key: packages-cache-{{ checksum ".meteor/versions" }}
paths:
- './.meteor/local/build'
- './.meteor/local/bundler-cache'
- './.meteor/local/isopacks'
- './.meteor/local/plugin-cache'
deploy_prod:
machine:
enabled: true
steps:
- run:
name: SSH - Installed build dependencies dependencies
command: |
ssh $SSH_USER@$SSH_HOST "sudo apt-get install -y jq moreutils"
- run:
name: SSH - Remove previous copy of the repo if present
halt_build_on_fail: false
command: |
ssh $SSH_USER@$SSH_HOST "rm ~/zencrepes_prod/ -R"
- run:
name: SSH - Clone Repo locally
command: |
ssh $SSH_USER@$SSH_HOST "git clone https://github.com/zencrepes/zencrepes.git ~/zencrepes_prod/"
- run:
name: SSH - Update settings.json with environment variable
command: |
ssh $SSH_USER@$SSH_HOST "sed -i \"s/GOOGLE_ANALYTICS/$PROD_GOOGLE_ANALYTICS/gi\" ~/zencrepes_prod/settings.json && sed -i \"s/METEOR_GITHUB_CLIENTID/$PROD_METEOR_GITHUB_CLIENTID/gi\" ~/zencrepes_prod/settings.json && sed -i \"s/METEOR_GITHUB_CLIENTSECRET/$PROD_METEOR_GITHUB_CLIENTSECRET/gi\" ~/zencrepes_prod/settings.json"
- run:
name: SSH - Update settings.json with menus content
command: |
ssh $SSH_USER@$SSH_HOST "jq --argfile menusfile ~/zencrepes_prod/settings_prod_menus.json '.public.menus = \$menusfile' ~/zencrepes_prod/settings.json|sponge ~/zencrepes_prod/settings.json"
- run:
name: SSH - Load settings.json in environment variable
command: |
ssh $SSH_USER@$SSH_HOST 'export PROD_METEOR_SETTINGS=$(cat ~/zencrepes_prod/settings.json); echo $PROD_METEOR_SETTINGS >> ~/prod_export.log'
- run:
name: SSH - Build Docker image
no_output_timeout: 320m
command: |
ssh $SSH_USER@$SSH_HOST "cd ~/zencrepes_prod/; docker build -t fgerthoffert/zencrepes ."
- run:
name: SSH - Run docker-compose down
halt_build_on_fail: false
command: |
ssh $SSH_USER@$SSH_HOST "cd ~/zencrepes_prod/; docker-compose -f docker-compose_prod.yml down"
- run:
name: SSH - Run docker-compose up
command: |
ssh $SSH_USER@$SSH_HOST 'cd ~/zencrepes_prod/; export PROD_METEOR_SETTINGS=$(cat ~/zencrepes_prod/settings.json); docker-compose -f docker-compose_prod.yml up -d '
deploy_dev:
machine:
enabled: true
steps:
- run:
name: SSH - Installed build dependencies dependencies
command: |
ssh $SSH_USER@$SSH_HOST "sudo apt-get install -y jq moreutils"
- run:
name: SSH - Remove previous copy of the repo if present
halt_build_on_fail: false
command: |
ssh $SSH_USER@$SSH_HOST "rm ~/zencrepes_dev/ -R"
- run:
name: SSH - Clone Repo locally
command: |
ssh $SSH_USER@$SSH_HOST "git clone https://github.com/zencrepes/zencrepes.git ~/zencrepes_dev/"
- run:
name: SSH - Moving to develop branch
command: |
ssh $SSH_USER@$SSH_HOST "cd ~/zencrepes_dev/; git checkout develop"
- run:
name: SSH - Update settings.json with environment variable
command: |
ssh $SSH_USER@$SSH_HOST "sed -i \"s/GOOGLE_ANALYTICS/$DEV_GOOGLE_ANALYTICS/gi\" ~/zencrepes_dev/settings.json && sed -i \"s/METEOR_GITHUB_CLIENTID/$DEV_METEOR_GITHUB_CLIENTID/gi\" ~/zencrepes_dev/settings.json && sed -i \"s/METEOR_GITHUB_CLIENTSECRET/$DEV_METEOR_GITHUB_CLIENTSECRET/gi\" ~/zencrepes_dev/settings.json"
- run:
name: SSH - Update settings.json with menus content
command: |
ssh $SSH_USER@$SSH_HOST "jq --argfile menusfile ~/zencrepes_dev/settings_dev_menus.json '.public.menus = \$menusfile' ~/zencrepes_dev/settings.json|sponge ~/zencrepes_dev/settings.json"
- run:
name: SSH - Load settings.json in environment variable
command: |
ssh $SSH_USER@$SSH_HOST 'export DEV_METEOR_SETTINGS=$(cat ~/zencrepes_dev/settings.json); echo $DEV_METEOR_SETTINGS >> ~/dev_export.log'
- run:
name: SSH - Build Docker image
no_output_timeout: 320m
command: |
ssh $SSH_USER@$SSH_HOST "cd ~/zencrepes_dev/; docker build -t fgerthoffert/zencrepes ."
- run:
name: SSH - Run docker-compose down
halt_build_on_fail: false
command: |
ssh $SSH_USER@$SSH_HOST "cd ~/zencrepes_dev/; docker-compose -f docker-compose_dev.yml down"
- run:
name: SSH - Run docker-compose up
command: |
ssh $SSH_USER@$SSH_HOST 'cd ~/zencrepes_dev/; export DEV_METEOR_SETTINGS=$(cat ~/zencrepes_dev/settings.json); docker-compose -f docker-compose_dev.yml up -d'
workflows:
version: 2
build-and-deploy:
jobs:
- build
- deploy_prod:
requires:
- build
filters:
branches:
only: master
- deploy_dev:
requires:
- build
filters:
branches:
only: develop