@@ -75,7 +75,12 @@ function do_before_script() {
75
75
run_verbose git config --global user.name " ${GIT_COMMIT_USER_NAME} "
76
76
77
77
# Clone the destination repo.
78
- run_verbose git clone --branch=master https://github.com/${GITHUB_DEST_REPO} .git " ${dest_repo} "
78
+ if [ " ${TRAVIS_BRANCH} " == " master" ]
79
+ then
80
+ run_verbose git clone --branch=master https://github.com/${GITHUB_DEST_REPO} .git " ${dest_repo} "
81
+ else
82
+ run_verbose git clone --branch=master https://github.com/${GITHUB_PREVIEW_REPO} .git " ${dest_repo} "
83
+ fi
79
84
80
85
return 0
81
86
}
@@ -113,19 +118,13 @@ function do_script() {
113
118
fi
114
119
115
120
# ---------------------------------------------------------------------------
116
- # The deployment code is present here not in after_success,
121
+ # The deployment code is present here (and not in after_success) ,
117
122
# to break the build if not successful.
118
123
119
124
cd " ${dest_repo} "
120
125
121
126
touch " .nojekyll"
122
127
123
- if [ " ${TRAVIS_BRANCH} " != " master" ]
124
- then
125
- echo " Not on master branch, skip deploy."
126
- return 0;
127
- fi
128
-
129
128
if [ " ${TRAVIS_PULL_REQUEST} " != " false" ]
130
129
then
131
130
echo " A pull request, skip deploy."
@@ -150,7 +149,12 @@ function do_script() {
150
149
echo " Deploy to GitHub pages..."
151
150
152
151
# Must be quiet and have no output, to not reveal the key.
153
- git push --force --quiet " https://${GITHUB_TOKEN} @github.com/${GITHUB_DEST_REPO} " master > /dev/null 2>&1
152
+ if [ " ${TRAVIS_BRANCH} " == " master" ]
153
+ then
154
+ git push --force --quiet " https://${GITHUB_TOKEN} @github.com/${GITHUB_DEST_REPO} " master > /dev/null 2>&1
155
+ else
156
+ git push --force --quiet " https://${GITHUB_TOKEN} @github.com/${GITHUB_PREVIEW_REPO} " master > /dev/null 2>&1
157
+ fi
154
158
155
159
return 0
156
160
}
0 commit comments