Skip to content

Instantly share code, notes, and snippets.

@rtablada
Last active October 13, 2015 20:06
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 rtablada/50ab1d84b0e3f9c476d7 to your computer and use it in GitHub Desktop.
Save rtablada/50ab1d84b0e3f9c476d7 to your computer and use it in GitHub Desktop.
Simple script for running your broccoli build and pushing to Github Pages

Description

This script allows you to build your project with broccoli, add a new commit for your build (with a supplied message) and them push this to be deployed via Github Pages.

Things of Note

Before running this script you should have a clean git tree. Commit any changed files BEFORE running this script (you do not want to commit a build for files that haven't been commited yet).

Also note that this script is PRETTY fragile and focused on ONLY broccoli builds and pushing to GH-Pages. A similar approach could be used to send code to other sites and methods, but this may or may not be the best starting point.

Installation

To install this you will need to have the bash function in your terminal setup (.zshrc, .bash-profile, etc). The suggested method is this:

  • Open a new file called ~/gh-page.sh in your editor: subl ~/gh-page.sh
  • Paste the contents of the gh-page.sh file below into your new file
  • Open your .zshrc file with an editor: subl ~/.zshrc
  • Add source $HOME/gh-page.sh to the bottom of this file
  • Reload your terminal configuration source ~/.zshrc

NOTE if you use bash, you will want to do the same things as in .zshrc but in your .bash-profile

Use

Now that you have installed this script you should be able to run gh-page-deploy and pass an argument with your commit message for your build. For instance:

gh-page-deploy "Build 0.0.1"
#!/bin/sh
gh-page-deploy () {
rm -rf dist
broccoli build dist
git push origin :gh-pages
git checkout -b tmp-gh-page
git add dist && git commit -m $1
git subtree push --prefix dist origin gh-pages
git checkout -
git branch -D tmp-gh-page
rm -rf dist
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment