From 8de48276c2e6dafdfd739bbde1b673ee542f16a4 Mon Sep 17 00:00:00 2001 From: Tushar Makkar Date: Fri, 4 Nov 2016 10:22:26 +0530 Subject: [PATCH] Fix auto updation travis issue and adding commit, username, password and Building html from sphinx --- update_documentation.sh | 62 ++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/update_documentation.sh b/update_documentation.sh index 6ea9810..7651835 100644 --- a/update_documentation.sh +++ b/update_documentation.sh @@ -13,6 +13,11 @@ GIT_PASS="$2" FROM_BRANCH="master" TO_BRANCH="gh-pages" +# Needed for setting identity +git config --global user.email "tusharmakkar08@gmail.com" +git config --global user.name "Tushar Makkar" +git config --global push.default "simple" + # Get the current branch export PAGER=cat CURRENT_BRANCH=$(git log -n 1 --pretty=%d HEAD | cut -d"," -f3 | cut -d" " -f2 | cut -d")" -f1) @@ -21,29 +26,36 @@ echo "current branch is '$CURRENT_BRANCH'" # Create the URL to push merge to URL=$(git remote -v | head -n1 | cut -f2 | cut -d" " -f1) echo "Repo url is $URL" -PUSH_URL="https://$GIT_USER:$GIT_PASS@${URL:6}" - -if [ "$CURRENT_BRANCH" = "$FROM_BRANCH" ] ; then - # Checkout the dev branch - #git checkout $FROM_BRANCH && \ - #echo "Checking out $TO_BRANCH..." && \ - - # Checkout the latest stable - git fetch origin ${TO_BRANCH}:${TO_BRANCH} && \ - git checkout ${TO_BRANCH} && \ - - # Merge the dev into latest stable - echo "Merging changes..." && \ - git merge ${FROM_BRANCH} && \ - - # Push changes back to remote vcs - echo "Pushing changes..." && \ - git push ${PUSH_URL} && \ - echo "Merge complete!" || \ - echo "Error Occurred. Merge failed" -else - echo "Not on $FROM_BRANCH. Skipping merge" -fi +PUSH_URL="https://$GIT_USER:$GIT_PASS@${URL:8}" + +git remote set-url origin ${PUSH_URL} + +echo "Checking out $FROM_BRANCH..." && \ +git fetch origin ${FROM_BRANCH}:${FROM_BRANCH} && \ +git checkout ${FROM_BRANCH} + + +echo "Checking out $TO_BRANCH..." && \ +# Checkout the latest stable +git fetch origin ${TO_BRANCH}:${TO_BRANCH} && \ +git checkout ${TO_BRANCH} && \ + +# Merge the dev into latest stable +echo "Merging changes..." && \ +git merge ${FROM_BRANCH} && \ + +# Push changes back to remote vcs +echo "Pushing changes..." && \ +git push origin gh-pages &> /dev/null && \ +echo "Merge complete!" || \ +echo "Error Occurred. Merge failed" + +export PYTHONPATH=${PYTHONPATH}:$(pwd):$(pwd)/voluptuous + +pip install -r requirements.txt && sphinx-apidoc -o docs -f voluptuous && +cd docs && make html || +echo "Sphinx not able to generate HTML" -pip install -r requirements.txt -sphinx-apidoc -o docs -f voluptuous +git status && git add . && +git commit -m "Auto updating documentation from $CURRENT_BRANCH" && +git push origin gh-pages &> /dev/null && echo "Documentation pushed"