Skip to content

Instantly share code, notes, and snippets.

@nothingismagick
Forked from danmichaelo/post-commit
Last active March 11, 2019 10:40
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 nothingismagick/bd5d2904cc35040750ebd74787528d3b to your computer and use it in GitHub Desktop.
Save nothingismagick/bd5d2904cc35040750ebd74787528d3b to your computer and use it in GitHub Desktop.
Git post-commit: update api docs on gh-pages branch for GitHub Pages
#!/usr/bin/env bash
###
### The following block runs after commit to "master" branch
###
if [ `git rev-parse --abbrev-ref HEAD` == "master" ]; then
echo
echo "Updating API documentation at the gh-pages branch..."
echo
# Switch to gh-pages branch to sync it with master
###################################################################
git checkout gh-pages
# Checkout src directory from master
###################################################################
git checkout master -- src
# Re-generate API docs
###################################################################
# DO SOMETHING HERE
# Add updated docs and commit
###################################################################
git add api_docs
git commit -m ":eyes: Update API docs after commit to master branch"
# Push
###################################################################
git push origin gh-pages
# Finally, switch back to the master branch and exit block
git checkout master
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment