This repository has been archived by the owner on Oct 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 505
/
Copy pathshipitfile.js
86 lines (65 loc) · 2.41 KB
/
shipitfile.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
var copyObject = require('copy-object');
var gitHelper = require('./git-helper');
var fs = require('fs');
var env = JSON.parse(fs.readFileSync('.env.json'));
module.exports = function (shipit) {
require('shipit-deploy')(shipit);
var
gitInfo = gitHelper.getLocalInfo(),
config = {
servers: 'deploy@142.4.202.189:22022',
workspace: '/tmp/docs.handsontable.com/' + gitInfo.branch,
repositoryUrl: 'https://github.com/handsontable/docs.git',
branch: gitInfo.branch,
ignores: ['.git', 'node_modules'],
rsync: ['--force', '--delete', '--delete-excluded', '-I', '--stats', '--chmod=ug=rwX'],
keepReleases: 3,
shallowClone: false
};
shipit.initConfig({
production: (function() {
config = copyObject(config);
config.deployTo = '/home/httpd/docs.handsontable.com/' + gitInfo.branch;
return config;
}()),
development: (function() {
config = copyObject(config);
config.deployTo = '/home/httpd/dev-docs.handsontable.com/' + gitInfo.branch;
config.keepReleases = 1;
return config;
}())
});
shipit.task('test', function() {
shipit.remote('pwd');
});
shipit.blTask('deploy', [
'deploy:init',
'deploy:fetch',
'deploy:update'
]);
shipit.on('updated', function() {
var path = shipit.releasePath;
shipit.remote('cd ' + path + ' && npm set progress=false && npm install --production').then(function() {
return shipit.remote('cd ' + path + ' && cp ../../../web.env .env.json');
}).then(function() {
return shipit.remote('cd ' + path + ' && grunt update-hot --hot-version=' + gitInfo.branch);
}).then(function() {
return shipit.remote('cd ' + path + ' && grunt build');
}).then(function() {
return shipit.remote('cd ' + path + ' && grunt generate-doc-versions');
}).then(function() {
return shipit.remote('cd ' + path + ' && grunt generate-disallow-for-robots');
}).then(function() {
gitHelper.setupGitApi(env.GITHUB_TOKEN);
return gitHelper.getHotLatestRelease();
}).then(function(objectInfo) {
if (!objectInfo) {
console.warn('Error retrieving the latest hot version from github.');
return;
}
return shipit.remote('cd ' + shipit.config.deployTo + '/../ && echo "' + objectInfo.tag_name + '" > latestHot');
}).then(function() {
shipit.start(['deploy:publish', 'deploy:clean']);
});
});
};