forked from adamogle/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshipitfile.js
75 lines (58 loc) · 2.09 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
const copyObject = require('copy-object');
const gitHelper = require('./git-helper');
const fs = require('fs');
const env = JSON.parse(fs.readFileSync('.env.json'));
module.exports = function(shipit) {
require('shipit-deploy')(shipit);
const gitInfo = gitHelper.getLocalInfo();
let config = {
servers: '[email protected]: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 --hot-version=' + gitInfo.branch);
}).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']);
});
});
};