@@ -143,14 +143,87 @@ jobs:
143
143
cf set-env analytics-reporter-api-staging API_DATA_GOV_SECRET "$API_SECRET"
144
144
cf restage analytics-reporter-api-staging
145
145
cf logout
146
+
147
+ main_deploy :
148
+ docker :
149
+ - image : cimg/node:16.19.1-browsers
150
+ environment :
151
+ POSTGRES_USER : postgres
152
+ NODE_ENV : test
153
+ - image : circleci/postgres:9.5-alpine
154
+ environment :
155
+ POSTGRES_DB : analytics-api-test
156
+ steps :
157
+ - checkout
158
+
159
+ - restore_cache :
160
+ keys :
161
+ - v1-dependencies-{{ checksum "package.json" }}
162
+ - v1-dependencies-
163
+
164
+ - run :
165
+ name : install dependencies
166
+ command : npm install
167
+
168
+ - save_cache :
169
+ paths :
170
+ - ./node_modules
171
+ key : v1-dependencies-{{ checksum "package.json" }}
172
+
173
+ - run :
174
+ name : run tests
175
+ command : npm test
176
+
177
+ - run :
178
+ name : Replace Data URL in manifest.yml file when deploying to production
179
+ command : |
180
+ sudo apt-get update
181
+ sudo apt-get install gettext
182
+ sed -i 's@name: analytics-reporter-api@name: analytics-reporter-api-production@g' manifest.yml
183
+ sed -i 's@- analytics-reporter-database@- analytics-reporter-database-production@g' manifest.yml
184
+ mv manifest.yml manifest.yml.src
185
+ envsubst < manifest.yml.src > manifest.yml
186
+
187
+ - run :
188
+ name : Run sed on entrypoint.sh when deploying to main
189
+ command : |
190
+ sed -i 's@NEW_RELIC_APP_NAME="analytics-reporter-api"@NEW_RELIC_APP_NAME="analytics-reporter-api-production"@g' entrypoint.sh
191
+
192
+ - run :
193
+ name : Delete Knexfile.js and drop sufffix on Knexfile.js.cloudgov
194
+ command : |
195
+ rm knexfile.js
196
+ mv knexfile.js.cloudgov knexfile.js
197
+ rm ./src/config.js
198
+ mv ./src/config.js.cloudgov ./src/config.js
199
+
200
+ - run :
201
+ name : Install CF CLI
202
+ command : |
203
+ sudo curl -v -L -o cf8-cli-installer_8.7.4_x86-64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=8.7.4'
204
+ sudo dpkg -i cf8-cli-installer_8.7.4_x86-64.deb
205
+
206
+ - run :
207
+ name : deploy
208
+ command : |
209
+ set -e
210
+ # Log into cloud.gov
211
+ cf api api.fr.cloud.gov
212
+ cf login -u $CF_PRODUCTION_SPACE_DEPLOYER_USERNAME -p $CF_PRODUCTION_SPACE_DEPLOYER_PASSWORD -o gsa-opp-analytics -s analytics-prod
213
+ cat manifest.yml
214
+ cf push -f "./manifest.yml"
215
+ cf set-env analytics-reporter-api-production API_DATA_GOV_SECRET "$API_SECRET"
216
+ cf restage analytics-reporter-api-production
217
+ cf logout
218
+
146
219
workflows :
147
220
develop_workflow :
148
221
jobs :
149
222
- develop_deploy :
150
223
filters :
151
224
branches :
152
225
only :
153
- - develop
226
+ - develop
154
227
155
228
staging :
156
229
jobs :
@@ -160,12 +233,11 @@ workflows:
160
233
only :
161
234
- stage
162
235
163
-
164
- # main_workflow:
165
- # jobs:
166
- # - main_deploy:
167
- # filters:
168
- # branches:
169
- # only:
170
- # - master
171
- #
236
+ main_workflow :
237
+ jobs :
238
+ - main_deploy :
239
+ filters :
240
+ branches :
241
+ only :
242
+ - master
243
+
0 commit comments