Skip to content

Instantly share code, notes, and snippets.

@danmichaelo
Last active March 31, 2020 11:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danmichaelo/9875056 to your computer and use it in GitHub Desktop.
Save danmichaelo/9875056 to your computer and use it in GitHub Desktop.
Git post-commit: update api docs on gh-pages branch for GitHub Pages
#!/bin/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
###################################################################
php vendor/bin/sami.php update sami.config.php -v
# 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