forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
34 lines (32 loc) · 718 Bytes
/
deploy.js
File metadata and controls
34 lines (32 loc) · 718 Bytes
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
const fetch = require('cross-fetch');
fetch('https://deploy-api.ops.csb.dev/image', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.DEPLOY_TOKEN}`,
},
body: JSON.stringify({
env: process.env.ENVIRONMENT,
image: 'client',
tag: process.env.CIRCLE_SHA1.substr(0, 7),
deploy: true,
}),
})
.then(x => {
if (!x.ok) {
return x.json().then(res => {
console.error(res);
throw new Error('Request failed');
});
}
return x.json();
})
.then(res => {
// eslint-disable-next-line
console.log(res);
process.exit(0);
})
.catch(e => {
console.error(e);
process.exit(1);
});