Skip to content

Instantly share code, notes, and snippets.

@Hydriz
Last active December 16, 2015 18:09
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 Hydriz/5475708 to your computer and use it in GitHub Desktop.
Save Hydriz/5475708 to your computer and use it in GitHub Desktop.
Script to build Sphinx documentation and push to relevant gh-pages branch.
#!/usr/bin/python
import os
repourl = "git@github.com:dumps/docs.git"
def worker():
# Step 1: Clone the repository
# os.chdir("/mnt") # Use a temporary working directory
os.system("git clone %s dumps-docs" % (repourl))
# Step 2: Build the documentation
os.chdir("dumps-docs")
os.system("make html")
# Step 3: Save the generated HTML content
os.system("cp _build/html ../html -R")
# Step 4: Change working branch to gh-pages
os.system("git checkout gh-pages")
# Step 5: Merge new changes in
os.system("find * -maxdepth 0 -name '.git' -prune -o -exec rm -rf '{}' ';'")
os.system("mv ../html/* .")
os.system("touch .nojekyll") # To build those underscore prefixed folders
# Step 6: Check-in everything into Git
os.system("git add *")
os.system('git commit -a -m "Updating documentation based on recent commit(s)"')
# Step 7: Deploy!
os.system("git push origin gh-pages")
# Step 8: Clean up and be ready for more
os.chdir("..")
os.system("rm -rf dumps-docs")
os.system("rm -rf html")
if __name__ == "__main__":
worker()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment