Skip to content

Commit 1ac1be7

Browse files
Xavier MetichecchiaXavier Metichecchia
authored andcommitted
Add staging code
1 parent 75d2588 commit 1ac1be7

File tree

1 file changed

+76
-7
lines changed

1 file changed

+76
-7
lines changed

.circleci/config.yml

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,75 @@ jobs:
7070
cf restage analytics-reporter-api-develop
7171
cf logout
7272
73+
staging_deploy_deploy:
74+
docker:
75+
- image: cimg/node:16.19.1-browsers
76+
environment:
77+
POSTGRES_USER: postgres
78+
NODE_ENV: test
79+
- image: circleci/postgres:9.5-alpine
80+
environment:
81+
POSTGRES_DB: analytics-api-test
82+
steps:
83+
- checkout
84+
85+
- restore_cache:
86+
keys:
87+
- v1-dependencies-{{ checksum "package.json" }}
88+
- v1-dependencies-
89+
90+
- run:
91+
name: install dependencies
92+
command: npm install
93+
94+
- save_cache:
95+
paths:
96+
- ./node_modules
97+
key: v1-dependencies-{{ checksum "package.json" }}
98+
99+
- run:
100+
name: run tests
101+
command: npm test
102+
103+
- run:
104+
name: Replace Data URL in manifest.yml file when deploying to staging
105+
command: |
106+
sudo apt-get update
107+
sudo apt-get install gettext
108+
sed -i 's@name: analytics-reporter-api@name: analytics-reporter-api-staging@g' manifest.yml
109+
sed -i 's@- analytics-reporter-database@- analytics-reporter-database-staging
110+
mv manifest.yml manifest.yml.src
111+
envsubst < manifest.yml.src > manifest.yml
112+
113+
- run:
114+
name: Run sed on entrypoint.sh when deploying to staging
115+
command: |
116+
sed -i 's@NEW_RELIC_APP_NAME="analytics-reporter-api"@NEW_RELIC_APP_NAME="analytics-reporter-api-staging"@g' entrypoint.sh
117+
118+
- run:
119+
name: Delete Knexfile.js and drop sufffix on Knexfile.js.cloudgov
120+
command: |
121+
rm knexfile.js
122+
mv knexfile.js.cloudgov knexfile.js
123+
124+
- run:
125+
name: Install CF CLI
126+
command: |
127+
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'
128+
sudo dpkg -i cf8-cli-installer_8.7.4_x86-64.deb
129+
130+
- run:
131+
name: deploy
132+
command: |
133+
set -e
134+
# Log into cloud.gov
135+
cf api api.fr.cloud.gov
136+
cf login -u $CF_STAGING_SPACE_DEPLOYER_USERNAME -p $CF_STAGING_SPACE_DEPLOYER_PASSWORD -o gsa-opp-analytics -s analytics-staging
137+
cat manifest.yml
138+
cf push -f "./manifest.yml"
139+
cf set-env analytics-reporter-api-staging API_DATA_GOV_SECRET "$API_SECRET"
140+
cf restage analytics-reporter-api-staging
141+
cf logout
73142
workflows:
74143
develop_workflow:
75144
jobs:
@@ -79,13 +148,13 @@ workflows:
79148
only:
80149
- develop
81150

82-
# staging:
83-
# jobs:
84-
# # - staging_deploy:
85-
# filters:
86-
# branches:
87-
# only:
88-
# - staging
151+
staging:
152+
jobs:
153+
- staging_deploy:
154+
filters:
155+
branches:
156+
only:
157+
- staging
89158

90159
# main_workflow:
91160
# jobs:

0 commit comments

Comments
 (0)