|
| 1 | +#!/bin/sh |
| 2 | +# ideas used from https://gist.github.com/motemen/8595451 |
| 3 | + |
| 4 | +# Based on https://github.com/eldarlabs/ghpages-deploy-script/blob/master/scripts/deploy-ghpages.sh |
| 5 | +# Used with their MIT license https://github.com/eldarlabs/ghpages-deploy-script/blob/master/LICENSE |
| 6 | + |
| 7 | +# abort the script if there is a non-zero error |
| 8 | +set -e |
| 9 | + |
| 10 | +# show where we are on the machine |
| 11 | +pwd |
| 12 | +remote=$(git config remote.origin.url) |
| 13 | + |
| 14 | +# make a directory to put the gp-pages branch |
| 15 | +mkdir gh-pages-branch |
| 16 | +cd gh-pages-branch |
| 17 | +# now lets setup a new repo so we can update the gh-pages branch |
| 18 | +git config --global user.email "$GH_EMAIL" > /dev/null 2>&1 |
| 19 | +git config --global user.name "$GH_NAME" > /dev/null 2>&1 |
| 20 | +git init |
| 21 | +git remote add --fetch origin "$remote" |
| 22 | + |
| 23 | +# switch into the the gh-pages branch |
| 24 | +if git rev-parse --verify origin/gh-pages > /dev/null 2>&1 |
| 25 | +then |
| 26 | + git checkout gh-pages |
| 27 | + # delete any old site as we are going to replace it |
| 28 | + # Note: this explodes if there aren't any, so moving it here for now |
| 29 | + git rm -rf . |
| 30 | +else |
| 31 | + git checkout --orphan gh-pages |
| 32 | +fi |
| 33 | + |
| 34 | +cd "../" |
| 35 | +make build_deploy |
| 36 | +cd gh-pages-branch |
| 37 | + |
| 38 | +# copy over or recompile the new site |
| 39 | +cp -a "../_site/." . |
| 40 | + |
| 41 | +# stage any changes and new files |
| 42 | +git add -A |
| 43 | +# now commit, ignoring branch gh-pages doesn't seem to work, so trying skip |
| 44 | +git commit --allow-empty -m "Deploy to GitHub pages [ci skip]" |
| 45 | +# and push, but send any output to /dev/null to hide anything sensitive |
| 46 | +git push --force --quiet origin gh-pages |
| 47 | +# go back to where we started and remove the gh-pages git repo we made and used |
| 48 | +# for deployment |
| 49 | +cd .. |
| 50 | +rm -rf gh-pages-branch |
| 51 | + |
| 52 | +echo "Finished Deployment!" |
0 commit comments