-
Notifications
You must be signed in to change notification settings - Fork 0
/
flightplan.js
41 lines (35 loc) · 1013 Bytes
/
flightplan.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
"use strict";
const exec = require("child_process").exec;
const plan = require("flightplan");
// Target
plan.target("production", [
{
host: 'cafedev.org',
username: 'root',
agent: process.env.SSH_AUTH_SOCK
}
]);
plan.local(function(local) {
local.log("Building...");
local.waitFor(function(done) {
exec("npm run build", function(err) {
if (err) {
throw new Error("Failed building.");
}
(done)();
});
});
});
plan.local(function(local) {
local.log("Archiving...");
local.exec("cd build && tar -czf deploy.tar.gz *");
local.exec("mv build/deploy.tar.gz ./");
local.log("Transferring...");
local.transfer("deploy.tar.gz", "/tmp/");
local.exec("rm deploy.tar.gz");
});
plan.remote(function(remote) {
remote.log("Extracting deployment package...");
remote.exec("tar -zxvf /tmp/deploy.tar.gz -C /usr/share/nginx/cafedev");
remote.exec("rm /tmp/deploy.tar.gz");
});