Skip to content

Instantly share code, notes, and snippets.

@jeffreysbrother
Created January 27, 2018 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreysbrother/9908979734d59805c85771f75fa69ab2 to your computer and use it in GitHub Desktop.
Save jeffreysbrother/9908979734d59805c85771f75fa69ab2 to your computer and use it in GitHub Desktop.
var plan = require('flightplan');
var username = 'logicfo3';
plan.target('production', [
{
host: '69.195.124.76',
username: username,
privateKey: '/Users/jc/.ssh/id_rsa',
agent: process.env.SSH_AUTH_SOCK
},
]);
plan.local(function(local) {
// prompt for passphrase (so we don't have to hardcode it in the object above)
var passphrase = local.prompt('Enter your passphrase:', { hidden: true });
plan.target().runtime.hosts.forEach(function(host) {
host.passphrase = passphrase;
});
// build jekyll for production
local.exec('JEKYLL_ENV=production jekyll build', {silent: true});
local.log('Copying files to remote host');
// copy only the _site directory to ~ of server
var filesToCopy = local.find('\_site -type f', {silent: true});
local.transfer(filesToCopy, '~');
});
plan.remote(function(remote) {
// move the contents of the copied folder to public_html/
remote.exec('cp -R ~/_site/* ~/public_html', {user: username});
// remove the temporary _site folder from the server
remote.exec('rm -rf ~/_site');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment