diff options
author | Brad Corso <bcorso@google.com> | 2021-01-19 19:10:25 -0800 |
---|---|---|
committer | Dagger Team <dagger-dev+copybara@google.com> | 2021-01-19 19:11:43 -0800 |
commit | 7caf468a57968ccd45c5351b28567990a14a21a2 (patch) | |
tree | acf3fdff7c6c52e2e71d60e7fe0b639ce0ceb112 /util | |
parent | 36bbd076dfe9c56375be3fdb106c2b6cd94f5b8d (diff) | |
download | dagger2-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-x | util/generate-latest-docs.sh | 14 |
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 |