Skip to content

Instantly share code, notes, and snippets.

@linhai86
Created March 3, 2020 19:46
Show Gist options
  • Save linhai86/290ac8e77505232eb729d7a6cf1d7587 to your computer and use it in GitHub Desktop.
Save linhai86/290ac8e77505232eb729d7a6cf1d7587 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
remote_repo=""
gp_branch="gh-pages"
publish_dir="_build/html"
# Build Sphinx doc
echo "Build documentation."
rm -rf ${publish_dir}
make html
# Create orphan gh-pages branch
echo "Create gh-pages branch."
cd "${publish_dir}"
git init
git checkout --orphan "${gp_branch}"
git remote add origin "${remote_repo}"
# Add and commit content
echo "Commit."
git add --all
commit_message="Automated deployment: $(date -u)"
git commit --allow-empty -m "${commit_message}"
# Publish to GitHub Pages
echo "Publish."
git push origin --force "${gp_branch}"
echo "GitHub Pages is successfully deployed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment