forked from excaliburjs/Excalibur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-docs.js
58 lines (51 loc) · 1.27 KB
/
deploy-docs.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
var Travis = require('travis-ci');
var repo = 'excaliburjs/excaliburjs.github.io';
var travis = new Travis({
version: '2.0.0',
headers: {
'User-Agent': 'Travis/1.0'
}
});
var branch = process.env.TRAVIS_BRANCH;
var tag = process.env.TRAVIS_TAG;
var pr = process.env.TRAVIS_PULL_REQUEST;
if (pr !== 'false') {
console.log('Skipping docs deployment, detected pull request');
return;
}
// build docs for tags and main only
if (tag) {
console.log('Current tag is `' + tag + '`');
} else if (branch == 'main') {
console.log('Current branch is `' + branch + '`');
} else {
console.log('Current branch is `' + branch + '`, skipping docs deployment...');
return;
}
console.log('Triggering remote build of edge docs...');
travis.authenticate(
{
github_token: process.env.GH_TOKEN
},
function (err, res) {
if (err) {
return console.error(err);
}
travis.repos(repo.split('/')[0], repo.split('/')[1]).builds.get(function (err, res) {
if (err) {
return console.error(err);
}
travis.requests.post(
{
build_id: res.builds[0].id
},
function (err, res) {
if (err) {
return console.error(err);
}
console.log(res.flash[0].notice);
}
);
});
}
);