Skip to content

Instantly share code, notes, and snippets.

@kaeff
Created October 12, 2014 19:47
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 kaeff/268a688cacd811837dfa to your computer and use it in GitHub Desktop.
Save kaeff/268a688cacd811837dfa to your computer and use it in GitHub Desktop.
Grunt task to deploy a static app to GitHub Pages

Used to deploy an JS/Grunt-based application to GitHub Pages. Used in an app generated using the yeoman's generator-angular.

Requirements / Assumptions

  • The compiled application resides in ./dist/. All files in this folder will be served.
  • In ./package.json, repository: { url: '...' } is configured to a ssh/http URL pointing to the app's repository
module.exports = function (grunt) {
grunt.initConfig({
packageJson: require('./package.json'),
shell: {
deploy: {
command: [
'git show head "--format=oneline" | head -n 1 > .git/commitmsg',
'cd dist',
'git init .',
'git add .',
'git commit -m "Deployed: $(cat .git/commitmsg)"',
'git push "<%= packageJson.repository.url %>" master:gh-pages --force',
'rm -rf .git'
].join('&&')
}
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment