Skip to content

Instantly share code, notes, and snippets.

@mlms13
Created August 25, 2014 15:32
Show Gist options
  • Save mlms13/4ed66cb920caf734ab1c to your computer and use it in GitHub Desktop.
Save mlms13/4ed66cb920caf734ab1c to your computer and use it in GitHub Desktop.
Deploy ignored, compiled files to Heroku with Gulp
// Use shell commands to commit your ignored, compiled files, push
// everything to Heroku, and reset your commit like it never happened
gulp.task('deploy', ['other', 'compilation', 'tasks'], function () {
var shell = require('shelljs');
if (!shell.which('git')) {
console.error('You need git installed to deploy.');
shell.exit(1);
}
// add the build directory, assuming it is named ./public
// change this to ./dist or ./build as necessary
if (shell.exec('git add --force ./public/**/*').code !== 0) {
console.error('Failed to add build directory to commit');
shell.exit(1);
}
// create a new commit with the build directory
if (shell.exec('git commit -m "Add the build folder"').code !== 0) {
console.error('Committing changes failed');
shell.exit(1);
}
// push our changes to a remote named heroku; replace this with
// a full url to the heroku repo if you don't have a named remote
if (shell.exec('git push --force heroku master').code !== 0) {
console.error('Pushing to heroku failed');
shell.exit(1);
}
// undo our commit, so the compiled files always stay out of our repo
if (shell.exec('git reset --hard HEAD~1').code !== 0) {
console.error('Reverting our commit failed');
shell.exit(1);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment