@@ -17,87 +17,85 @@ PAGES_TARGET_BRANCH="gh-pages"
1717LATEST_DOCS_BRANCH=" develop"
1818# TRAVIS_* variables are set by travis directly and only need to be if testing externally
1919
20- # Since we are running job matrix, only thie first job slave will need to do the work
21- if [[ " ${TRAVIS_JOB_NUMBER} " =~ \. 1$ ]]; then
22- # We don't want a pull request automatically updating the repository
23- if [ " $TRAVIS_PULL_REQUEST " == " false" ] && { [ " ${CURRENT_BRANCH} " == " ${LATEST_DOCS_BRANCH} " ] || [ -n " ${TRAVIS_TAG} " ]; }; then
20+ # We don't want a pull request automatically updating the repository
21+ if [ " $TRAVIS_PULL_REQUEST " == " false" ] && { [ " ${CURRENT_BRANCH} " == " ${LATEST_DOCS_BRANCH} " ] || [ -n " ${TRAVIS_TAG} " ]; }; then
2422
25- # ENV Variable checks are to help with configuration troubleshooting, they silently exit with unique message.
26- # Anyone one of them not set can be used to turn off this functionality.
23+ # ENV Variable checks are to help with configuration troubleshooting, they silently exit with unique message.
24+ # Anyone one of them not set can be used to turn off this functionality.
2725
28- # If a version of the project is not defined
29- [[ -n " ${UTPLSQL_VERSION} " ]] || { echo " variable UTPLSQL_VERSION is not defines or missing value" ; exit 0; }
30- # Fail if the markdown documentation is not present.
31- [[ -f ./docs/index.md ]] || { echo " file docs/index.md not found" ; exit 1; }
26+ # If a version of the project is not defined
27+ [[ -n " ${UTPLSQL_VERSION} " ]] || { echo " variable UTPLSQL_VERSION is not defines or missing value" ; exit 0; }
28+ # Fail if the markdown documentation is not present.
29+ [[ -f ./docs/index.md ]] || { echo " file docs/index.md not found" ; exit 1; }
3230
33- # Save some useful information
34- SHA=` git rev-parse --verify HEAD`
31+ # Save some useful information
32+ SHA=` git rev-parse --verify HEAD`
3533
36- # clone the repository and switch to PAGES_TARGET_BRANCH branch
37- mkdir pages
38- cd pages
39- git clone https://${github_api_token} @github.com/${UTPLSQL_REPO} .
34+ # clone the repository and switch to PAGES_TARGET_BRANCH branch
35+ mkdir pages
36+ cd pages
37+ git clone https://${github_api_token} @github.com/${UTPLSQL_REPO} .
4038
41- PAGES_BRANCH_EXISTS=$( git ls-remote --heads origin ${PAGES_TARGET_BRANCH} )
39+ PAGES_BRANCH_EXISTS=$( git ls-remote --heads origin ${PAGES_TARGET_BRANCH} )
4240
43- if [ -n " $PAGES_BRANCH_EXISTS " ] ; then
44- echo " Pages Branch Found"
45- git checkout ${PAGES_TARGET_BRANCH}
46- else
47- echo " Creating Pages Branch"
48- git checkout --orphan ${PAGES_TARGET_BRANCH}
49- git rm -rf .
50- fi
51- # clear out develop documentation directory and copy docs contents to it.
52- echo " updating 'develop' directory"
53- mkdir -p develop
54- rm -rf develop/** ./* || exit 0
55- cp -a ../docs/. ./develop
56- # If a Tagged Build then copy to it's own directory as well and to the 'latest' release directory
57- if [ -n " $TRAVIS_TAG " ]; then
58- echo " Creating ${UTPLSQL_VERSION} "
59- mkdir -p ${UTPLSQL_VERSION}
60- rm -rf ${UTPLSQL_VERSION} /** ./* || exit 0
61- cp -a ../docs/. ${UTPLSQL_VERSION}
62- echo " Populating 'latest' directory"
63- mkdir -p latest
64- rm -rf latest/** ./* || exit 0
65- cp -a ../docs/. latest
66- fi
67- # Stage changes for commit
68- git add .
69- # Check if there are doc changes, if none exit the script
70- if [[ -z ` git diff HEAD --exit-code` ]] && [ -n " ${PAGES_BRANCH_EXISTS} " ] ; then
71- echo " No changes to docs detected."
72- exit 0
73- fi
74- # Changes where detected, so we need to update the version log.
75- now=$( date +" %d %b %Y - %r" )
76- if [ ! -f index.md ]; then
77- echo " ---" >> index.md
78- echo " layout: default" >> index.md
79- echo " ---" >> index.md
80- echo " <!-- Auto generated from .travis/push_docs_to_gh_pages.sh -->" >> index.md
81- echo " # Documentation versions" >> index.md
82- echo " " >> index.md
83- echo " " >> index.md # - 7th line - placeholder for latest release doc
84- echo " " >> index.md # - 8th line - placeholder for develop branch doc
85- echo " " >> index.md
86- echo " ## Released Version Doc History" >> index.md
87- echo " " >> index.md
88- fi
89- # If build running on a TAG - it's a new release - need to add it to documentation
90- if [ -n " ${TRAVIS_TAG} " ]; then
91- sed -i ' 7s@.*@' " - [Latest ${TRAVIS_TAG} documentation](latest/) - Created $now " ' @' index.md
92- # add entry to the top of version history (line end of file - ## Released Version Doc History
93- sed -i ' 12i' " - [${TRAVIS_TAG} documentation](${UTPLSQL_VERSION} /) - Created $now " index.md
94- fi
95- # replace 4th line in log
96- sed -i ' 8s@.*@' " - [Latest development version](develop/) - Created $now " ' @' index.md
97- # Add and Commit the changes back to pages repo.
98- git add .
99- git commit -m " Deploy to gh-pages branch: base commit ${SHA} "
100- # Now that we're all set up, we can push.
101- git push --quiet origin HEAD:${PAGES_TARGET_BRANCH}
41+ if [ -n " $PAGES_BRANCH_EXISTS " ] ; then
42+ echo " Pages Branch Found"
43+ git checkout ${PAGES_TARGET_BRANCH}
44+ else
45+ echo " Creating Pages Branch"
46+ git checkout --orphan ${PAGES_TARGET_BRANCH}
47+ git rm -rf .
10248 fi
49+ # clear out develop documentation directory and copy docs contents to it.
50+ echo " updating 'develop' directory"
51+ mkdir -p develop
52+ rm -rf develop/** ./* || exit 0
53+ cp -a ../docs/. ./develop
54+ # If a Tagged Build then copy to it's own directory as well and to the 'latest' release directory
55+ if [ -n " $TRAVIS_TAG " ]; then
56+ echo " Creating ${UTPLSQL_VERSION} "
57+ mkdir -p ${UTPLSQL_VERSION}
58+ rm -rf ${UTPLSQL_VERSION} /** ./* || exit 0
59+ cp -a ../docs/. ${UTPLSQL_VERSION}
60+ echo " Populating 'latest' directory"
61+ mkdir -p latest
62+ rm -rf latest/** ./* || exit 0
63+ cp -a ../docs/. latest
64+ fi
65+ # Stage changes for commit
66+ git add .
67+ # Check if there are doc changes, if none exit the script
68+ if [[ -z ` git diff HEAD --exit-code` ]] && [ -n " ${PAGES_BRANCH_EXISTS} " ] ; then
69+ echo " No changes to docs detected."
70+ exit 0
71+ fi
72+ # Changes where detected, so we need to update the version log.
73+ now=$( date +" %d %b %Y - %r" )
74+ if [ ! -f index.md ]; then
75+ echo " ---" >> index.md
76+ echo " layout: default" >> index.md
77+ echo " ---" >> index.md
78+ echo " <!-- Auto generated from .travis/push_docs_to_gh_pages.sh -->" >> index.md
79+ echo " # Documentation versions" >> index.md
80+ echo " " >> index.md
81+ echo " " >> index.md # - 7th line - placeholder for latest release doc
82+ echo " " >> index.md # - 8th line - placeholder for develop branch doc
83+ echo " " >> index.md
84+ echo " ## Released Version Doc History" >> index.md
85+ echo " " >> index.md
86+ fi
87+ # If build running on a TAG - it's a new release - need to add it to documentation
88+ if [ -n " ${TRAVIS_TAG} " ]; then
89+ sed -i ' 7s@.*@' " - [Latest ${TRAVIS_TAG} documentation](latest/) - Created $now " ' @' index.md
90+ # add entry to the top of version history (line end of file - ## Released Version Doc History
91+ sed -i ' 12i' " - [${TRAVIS_TAG} documentation](${UTPLSQL_VERSION} /) - Created $now " index.md
92+ fi
93+ # replace 4th line in log
94+ sed -i ' 8s@.*@' " - [Latest development version](develop/) - Created $now " ' @' index.md
95+ # Add and Commit the changes back to pages repo.
96+ git add .
97+ git commit -m " Deploy to gh-pages branch: base commit ${SHA} "
98+ # Now that we're all set up, we can push.
99+ git push --quiet origin HEAD:${PAGES_TARGET_BRANCH}
103100fi
101+
0 commit comments