Create a gist now

Instantly share code, notes, and snippets.

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.');
// 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');
// 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');
// 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');
// 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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment