Skip to content

Instantly share code, notes, and snippets.

@thelinuxlich
Last active September 13, 2017 07:36
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thelinuxlich/2204d383696d3a263fcb to your computer and use it in GitHub Desktop.
Save thelinuxlich/2204d383696d3a263fcb to your computer and use it in GitHub Desktop.
Shipitfile example
var project_name = "YOUR_PROJECT_NAME",
project_url = 'YOUR_GIT_URL',
project_destination_server = 'USER@SERVER',
project_destination_dir = '/PROJECT_DIRECTORY',
webhookUri = "SLACK_TOKEN_URI",
Slack = require('slack-node'),
slack = new Slack(),
notify = function(text) {
slack.webhook({
channel: "#notifications",
username: "deployer",
text: text
}, function(err, response) {
if (err) {
console.error(err);
}
});
};
slack.setWebHook(webhookUri);
module.exports = function(shipit) {
require('shipit-deploy')(shipit);
shipit.initConfig({
default: {
workspace: '/tmp/' + project_name,
deployTo: project_destination_dir,
repositoryUrl: project_url,
ignores: ['.git'],
keepReleases: 2,
shallowClone: true
},
production: {
servers: project_destination_server
}
});
shipit.on("deploy", function() {
shipit.log("deploy started!");
notify(":pushpin: " + project_name + " *Deploying...*");
});
var run_tasks = function(tasks) {
var cwd = shipit.releasePath,
unfold_tasks = function() {
if (tasks.length > 0) {
var task = "cd " + cwd + " && " + tasks.splice(0, 1)[0];
return function() {
shipit.remote(task, {
cwd: cwd
}, unfold_tasks(fns));
};
} else {
return function() {
shipit.log("deploy finished!");
notify(":zap: " + project_name + " *Deployed!*");
};
}
};
unfold_tasks()();
};
shipit.on("published", function() {
run_tasks(["npm install", "git submodule init", "git submodule update", "git submodule foreach git pull origin master","systemctl restart service"]);
});
shipit.on("rollback", function() {
shipit.log("rolling back changes!");
notify(":zap: " + project_name + " *Rolling back...*");
});
shipit.on("err", function(err) {
shipit.log("An error occurred!", err);
notify(":boom: " + project_name + " *" + err.err + "*");
});
};
@40818419
Copy link

40818419 commented Aug 26, 2016

'deploy:publish' errored after 487 ms
ReferenceError: fns is not defined

shall be "tasks" instead "fns", right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment