Skip to content

Instantly share code, notes, and snippets.

@jeandat
Last active March 18, 2017 01:09
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 jeandat/25b1d3b971902ecc3600b9d66e0520c4 to your computer and use it in GitHub Desktop.
Save jeandat/25b1d3b971902ecc3600b9d66e0520c4 to your computer and use it in GitHub Desktop.
Little idea to deploy a folder on the gh-pages branch automatically.

Deploy on Github Pages from a folder

  1. Create the gh-pages branch and initialize it with nothing except a .gitkeep file.

  2. Add gh-pages/ folder in .gitignore to keep git history clean.

  3. From the master branch, clone the gh-pages branch into the gh-pages folder:

$ git clone <repo> --branch gh-pages gh-pages
  1. Create a deploy script in package.json.

For instance for a little project of mine using the angular CLI:

"deploy": "rm -f gh-pages/* && ng build --base-href 'https://USERNAME.github.io/PROJECT/' && cp dist/* gh-pages/ && cd gh-pages && git add --all && git commit -m \"Release at $(date)\" && git push"

That's all.

More ideas here.

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