Skip to content

Commit 6a9668d

Browse files
committed
Avoid build failure if there is nothing new to push
1 parent 3c7df9c commit 6a9668d

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

scripts/update_docs.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,19 @@ git submodule add -b gh-pages \
2323
ghpages
2424
cp -R docs/_build/html/* ghpages/
2525
cd ghpages
26+
# allow "git add" to fail if there aren't new files.
27+
set +e
2628
git add .
27-
# Commit to gh-pages branch to apply changes.
28-
git config user.name "selfiebot"
29-
git commit -m "Update docs after merge to master."
30-
git push \
31-
"https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME}" \
32-
HEAD:gh-pages
29+
set -e
30+
git status
31+
# H/T: https://github.com/dhermes
32+
if [[ -n "$(git status --porcelain)" ]]; then
33+
# Commit to gh-pages branch to apply changes.
34+
git config user.name "selfiebot"
35+
git commit -m "Update docs after merge to master."
36+
git push \
37+
"https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME}" \
38+
HEAD:gh-pages
39+
else
40+
echo "Nothing to commit. Exiting without pushing changes."
41+
fi

scripts/update_wheels_project.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,18 @@ echo "${TRAVIS_COMMIT}" > ${FRESH_REPO_DIR}/LATEST_COMMIT
4444
# Display git status and push LATEST_COMMIT. #
4545
##############################################
4646
cd ${FRESH_REPO_DIR}
47-
git add LATEST_COMMIT
4847

48+
# allow "git add" to fail if there aren't new files.
49+
# this can happen if we re-run builds on travis.
50+
set +e
51+
git add LATEST_COMMIT
52+
set -e
4953
git status
50-
git commit -m "Main project gcloud-python has been updated."
51-
git status
52-
git push origin master
54+
# H/T: https://github.com/dhermes
55+
if [[ -n "$(git status --porcelain)" ]]; then
56+
git commit -m "Main project gcloud-python has been updated."
57+
git status
58+
git push origin master
59+
else
60+
echo "Nothing to commit. Exiting without pushing changes."
61+
fi

0 commit comments

Comments
 (0)