Skip to content

Instantly share code, notes, and snippets.

@titaniumbones
Last active December 7, 2017 19:14
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 titaniumbones/0ade63f2c67b2b3c1df8f5c152840268 to your computer and use it in GitHub Desktop.
Save titaniumbones/0ade63f2c67b2b3c1df8f5c152840268 to your computer and use it in GitHub Desktop.
Post-commit hook to push to gh-pages. Also pushes master to origin. Intended for use in a gitflow worflow, in other cases you might not want ot push master to origin.
#!/bin/bash
push_branch=master
cur_branch=$(git rev-parse --abbrev-ref HEAD)
# only run if commit is to master
if [ "$cur_branch" == "$push_branch" ]; then
if [ "$(git status -uno --porcelain)" ]; then
echo "uncommitted changes, can't push";
else
git push origin master
# recreate gh-pages, checkout, collect sanitized info, remove sensitive info, commit, push, change back to develop
git branch -f gh-pages &&
git checkout gh-pages && node utils/collectjson.js &&
rm students/*.json && git add utils/allstudents.js &&
git commit -a -m "sanitize for gh-pages
after $(git log -1 --pretty=%h): $(git log -1 --pretty=%B)" &&
git push -f origin gh-pages --quiet &&
git checkout develop --quiet && git merge master --quiet
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment