Last active
August 29, 2015 14:02
-
-
Save koistya/9e7045e5b777d5bc4922 to your computer and use it in GitHub Desktop.
Deploy to GitHub Pages with Gulp.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var gutil = require('gulp-util'); | |
var path = require('path'); | |
// Settings | |
var deployUrl = 'https://github.com/{name}/{name}.github.io.git'; | |
var buildPath = './build'; | |
// Build website into the `./build` folder | |
gulp.task('build', function () { | |
// Your custom build steps go here | |
}); | |
// Deploy from the `./build` folder to GitHub Pages. | |
// For more information, please visit: https://pages.github.com | |
gulp.task('deploy', ['build'], function (cb) { | |
var exec = require('child_process').exec; | |
var cwd = path.join(__dirname, buildPath); | |
var cmd = 'git init && ' + | |
'git remote add origin ' + deployUrl + ' && ' + | |
'git add . && git commit -m Release && ' + | |
'git push -f origin master'; | |
exec(cmd, { 'cwd': cwd }, function (err, stdout, stderr) { | |
if (err !== null) { | |
cb(err); | |
} else { | |
gutil.log(stdout, stderr); | |
cb(); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gulpjs/gulp#501