Skip to content

Instantly share code, notes, and snippets.

@koistya
Last active August 29, 2015 14:02
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 koistya/9e7045e5b777d5bc4922 to your computer and use it in GitHub Desktop.
Save koistya/9e7045e5b777d5bc4922 to your computer and use it in GitHub Desktop.
Deploy to GitHub Pages with Gulp.js
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();
}
});
});
@koistya
Copy link
Author

koistya commented Jun 1, 2014

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