Last active
December 16, 2015 18:09
-
-
Save Hydriz/5475708 to your computer and use it in GitHub Desktop.
Script to build Sphinx documentation and push to relevant gh-pages branch.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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