-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathdeploy.js
executable file
·99 lines (89 loc) · 2.81 KB
/
deploy.js
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
#!/usr/bin/env node
const fs = require('fs');
const shell = require('shelljs');
const path = require('path');
const { gitSha } = require('./utils');
const { branchName } = require('./utils/branch-name');
const { getConfig } = require('../packages/build-tools/utils/config-store');
const { fileExists } = require('../packages/build-tools/utils/general');
const { TRAVIS, TRAVIS_TAG } = require('./utils/travis-vars');
const { NOW_TOKEN } = process.env;
let setCheckRun, outputBanner, deployedUrlPretty, deployedUrl;
async function init() {
try {
let config = await getConfig();
// if (TRAVIS) {
// setCheckRun = require('./check-run').setCheckRun;
// outputBanner = require('ci-utils').outputBanner;
// await setCheckRun({
// name: 'Deploy - now.sh (basic)',
// status: 'in_progress',
// });
// outputBanner('Starting deploy...');
// }
try {
// experimental approach for speeding up non-master / release / tagged version deploys
// if (
// !TRAVIS_TAG &&
// !branchName.includes('master') &&
// !branchName.includes('release') &&
// !branchName.includes('next')
// ) {
// shell.exec(
// `cp ${path.join(process.cwd(), 'now.v2.json')} ${path.join(
// process.cwd(),
// config.wwwDir,
// )}/now.json`,
// );
// deployedUrl = shell.exec(
// `cd ${path.join(
// process.cwd(),
// config.wwwDir,
// )} && now deploy --meta gitSha="${gitSha}" --token=${NOW_TOKEN} --no-verify`,
// );
// } else {
// }
deployedUrl = shell.exec(
`npx now --meta gitSha="${gitSha}" --token=${NOW_TOKEN}`,
).stdout;
deployedUrlPretty = deployedUrl.trim();
// if (TRAVIS) {
// await setCheckRun({
// status: 'completed',
// name: 'Deploy - now.sh (basic)',
// conclusion: 'success',
// output: {
// title: 'Now.sh Basic Deploy',
// summary: `
// - ${deployedUrlPretty}
// `.trim(),
// },
// });
// }
} catch (error) {
console.log(error);
console.error('Error deploying:');
console.log(error.stdout, error.stderr);
// if (TRAVIS) {
// await setCheckRun({
// status: 'completed',
// name: 'Deploy - now.sh (basic)',
// conclusion: 'failure',
// output: {
// title: 'Now.sh Deploy failure',
// summary: `
// ${error.stdout}
// ${error.stderr}
// `.trim(),
// },
// });
// }
process.exit(1);
}
} catch (error) {
console.log('Error');
console.error(error);
process.exit(1);
}
}
init();