aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorBrad Corso <bcorso@google.com>2021-01-19 19:10:25 -0800
committerDagger Team <dagger-dev+copybara@google.com>2021-01-19 19:11:43 -0800
commit7caf468a57968ccd45c5351b28567990a14a21a2 (patch)
treeacf3fdff7c6c52e2e71d60e7fe0b639ce0ceb112 /util
parent36bbd076dfe9c56375be3fdb106c2b6cd94f5b8d (diff)
downloaddagger2-7caf468a57968ccd45c5351b28567990a14a21a2.tar.gz
Prevent committing docs if there are no changes to avoid failing the travis build.
See https://travis-ci.org/github/google/dagger/builds/755270606 Before CL/352657712 util/generate-latest-docs.sh was allowed to fail silently because it was in the "after_success" section of travis.yml. However, now it is in the "scripts" section which will fail the build. We could mark the job as "allow_failures" but it would be nice to catch other legit types of failures in this script. RELNOTES=N/A PiperOrigin-RevId: 352702083
Diffstat (limited to 'util')
-rwxr-xr-xutil/generate-latest-docs.sh14
1 files changed, 11 insertions, 3 deletions
diff --git a/util/generate-latest-docs.sh b/util/generate-latest-docs.sh
index 8e9304c87..e0e34f9aa 100755
--- a/util/generate-latest-docs.sh
+++ b/util/generate-latest-docs.sh
@@ -21,10 +21,18 @@ if [ "$TRAVIS_REPO_SLUG" == "google/dagger" ] && \
unzip "$JAVADOC_JAR" -d api/latest
rm -rf api/latest/META-INF/
git add -f api/latest
- git commit -m "Latest javadoc on successful travis build $TRAVIS_BUILD_NUMBER auto-pushed to gh-pages"
- git push -fq origin gh-pages > /dev/null
- echo -e "Published Javadoc to gh-pages.\n"
+ # Check if there are any changes before committing, otherwise attempting
+ # to commit will fail the build (https://stackoverflow.com/a/2659808).
+ git diff-index --quiet HEAD --
+ hasChanges=$? # The exist status is 0 (no changes) or 1 (changes)
+ if [ $hasChanges -eq 0 ]; then
+ echo -e "Skipping publishing docs since no changes were detected."
+ else
+ git commit -m "Latest javadoc on successful travis build $TRAVIS_BUILD_NUMBER auto-pushed to gh-pages"
+ git push -fq origin gh-pages > /dev/null
+ echo -e "Published Javadoc to gh-pages.\n"
+ fi
else
echo -e "Not publishing docs for jdk=${TRAVIS_JDK_VERSION} and branch=${TRAVIS_BRANCH}"
fi