Skip to content

Commit ddb70e6

Browse files
committed
Change deploy script
1 parent 68c87e9 commit ddb70e6

File tree

2 files changed

+41
-15
lines changed

2 files changed

+41
-15
lines changed

.circleci/config.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,6 @@ commands:
168168
- run:
169169
name: Build Application
170170
command: yarn build:prod
171-
- run:
172-
name: Mark Sentry release
173-
command: |
174-
if [ "${CIRCLE_BRANCH}" == "master" ]; then
175-
node packages/app/scripts/sentry-create-release.js
176-
fi
177171
- save_cache: *save_prod_build_cache
178172
- save_cache: *save_prod_result
179173
- run:
@@ -306,17 +300,18 @@ jobs:
306300
docker:
307301
- image: curlimages/curl:7.65.3
308302
steps:
303+
- run:
304+
name: Mark Sentry release
305+
command: node packages/app/scripts/sentry-create-release.js
306+
- checkout_with_cache
307+
- restore_cache: *restore_deps_cache
308+
- attach_workspace: *attach_deps_workspace
309309
- run:
310310
name: Deploy Image
311-
command: |
312-
curl --request POST \
313-
--url https://deployment-api.lbogdan.ro/image \
314-
--header 'Accept: */*' \
315-
--header 'Authorization: Bearer '$DEPLOY_TOKEN'' \
316-
--header 'Content-Type: application/json' \
317-
--header 'Postman-Token: e9e28b11-1889-488e-92c8-d8e41ef24e75' \
318-
--header 'cache-control: no-cache' \
319-
--data '{ "env": "production", "image": "client", "tag": "'${CIRCLE_SHA1:0:7}'", "deploy": true }'
311+
command: node packages/app/scripts/deploy.js
312+
- run:
313+
name: Deploy Sentry release
314+
command: node packages/app/scripts/sentry-deploy-release.js
320315

321316
################################
322317
# Workflows

packages/app/scripts/deploy.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const fetch = require('whatwg-fetch');
2+
3+
fetch('https://deployment-api.lbogdan.ro/image', {
4+
method: 'POST',
5+
headers: {
6+
'Content-Type': 'application/json',
7+
Authorization: `Bearer ${process.env.DEPLOY_TOKEN}`,
8+
},
9+
body: JSON.stringify({
10+
env: 'production',
11+
image: 'client',
12+
tag: process.env.CIRCLE_SHA1.substr(0, 7),
13+
deploy: true,
14+
}),
15+
})
16+
.then(x => {
17+
if (!x.ok) {
18+
throw new Error('Request failed');
19+
}
20+
21+
return x.json();
22+
})
23+
.then(res => {
24+
// eslint-disable-next-line
25+
console.log(res);
26+
process.exit(0);
27+
})
28+
.catch(e => {
29+
console.error(e);
30+
process.exit(1);
31+
});

0 commit comments

Comments
 (0)