-
Notifications
You must be signed in to change notification settings - Fork 58
/
deploy.js
63 lines (53 loc) · 1.39 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
const ghpages = require('gh-pages')
const path = require('path')
const fs = require('fs')
require('dotenv').config()
console.log('starting publish.js')
const DIR = process.env.CODE_GOV_DIR || path.join(__dirname, process.env.CODE_GOV_RELATIVE_DIR)
const env_vars = {
owner: process.env.OWNER,
repository: process.env.REPOSITORY,
branch: process.env.BRANCH,
baseurl: process.env.BASEURL,
api: process.env.CODE_GOV_API_KEY,
code_gov_repo: process.env.CODE_GOV_REPO,
dir: DIR
}
console.log('env_vars', env_vars)
try {
if (fs.existsSync('./dist/.gitignore')) {
console.log('unlinking ./dist/.gitignore')
fs.unlinkSync('./dist/.gitignore')
}
} catch (err) {
console.log(err)
}
if (!DIR) {
throw new Error('please specify CODE_GOV_DIR as an env variable')
}
const options = {
dotfiles: false,
repo: process.env.CODE_GOV_REPO || '[email protected]:GSA/code-gov-front-end'
}
if (process.env.CODE_GOV_BRANCH) {
options.branch = process.env.CODE_GOV_BRANCH
} else {
throw new Error('no branch specified')
}
console.log('options:', options)
// if (!process.env.CODE_GOV_REPO) {
// throw new Error("no repo specified")
// }
//
// if (!process.env.CODE_GOV_API_KEY) {
// throw new Error("no api specified")
// }
// ghpages.clean()
//
// ghpages.publish(DIR, options, err => {
// if (err) {
// console.error(err);
// } else {
// console.log("published successfully");
// }
// });