Skip to content

Commit 1c2b45a

Browse files
committed
Merge pull request googleapis#273 from silvolu/fix-docs-build
fix(build): execute git commit only if there have been changes
2 parents 5209fc0 + a067dab commit 1c2b45a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

scripts/build.sh

+11-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,15 @@ if [ "${TRAVIS_BRANCH}" == "master" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]
3535
set +e
3636
git add .
3737
set -e
38-
# commit to gh-pages branch to apply changes
39-
git config user.name "selfiebot"
40-
git commit -m "Update docs after merge to master"
41-
git push https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} HEAD:gh-pages
38+
git status
39+
# H/T: https://github.com/dhermes
40+
if [[ -n "$(git status --porcelain)" ]]; then
41+
# commit to gh-pages branch to apply changes
42+
git config user.name "selfiebot"
43+
git commit -m "Update docs after merge to master"
44+
git status
45+
git push https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} HEAD:gh-pages
46+
else
47+
echo "Nothing to commit. Exiting without pushing changes."
48+
fi
4249
fi

0 commit comments

Comments
 (0)