Skip to content

Commit dd81cb1

Browse files
committed
Skip docs/javadoc publish commit when nothing changed
The hardened gh-pages publish flow runs commitJavadoc/commitDocs under 'set -eo pipefail'. When the regenerated javadoc or docs are byte-identical to what is already published, 'git add' stages nothing and 'git commit' exits 1 with "nothing to commit, working tree clean", which set -e turns into a build failure (the previous sh-based flow without set -e silently tolerated this). Guard the commit/push behind 'git diff --cached --quiet' so a no-op republish is treated as a clean skip while still failing on real push errors, and always remove the worktree afterwards.
1 parent 131325d commit dd81cb1

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

build.gradle

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,12 @@ tasks.register("commitJavadoc", Exec) {
293293
"""
294294
set -eo pipefail
295295
git -C build/gh-pages-javadoc add javadoc
296-
git -C build/gh-pages-javadoc -c user.name="Spock Framework Robot" -c user.email="dev@forum.spockframework.org" commit -qm "Publish javadoc/$variantLessVersion"
297-
git -C build/gh-pages-javadoc push "https://\$GITHUB_TOKEN@github.com/spockframework/spock.git" gh-pages 2>&1 | sed "s/\$GITHUB_TOKEN/xxx/g"
296+
if git -C build/gh-pages-javadoc diff --cached --quiet; then
297+
echo "No javadoc changes to publish for $variantLessVersion"
298+
else
299+
git -C build/gh-pages-javadoc -c user.name="Spock Framework Robot" -c user.email="dev@forum.spockframework.org" commit -qm "Publish javadoc/$variantLessVersion"
300+
git -C build/gh-pages-javadoc push "https://\$GITHUB_TOKEN@github.com/spockframework/spock.git" gh-pages 2>&1 | sed "s/\$GITHUB_TOKEN/xxx/g"
301+
fi
298302
git worktree remove --force build/gh-pages-javadoc
299303
"""
300304
}
@@ -345,8 +349,12 @@ tasks.register("commitDocs", Exec) {
345349
"""
346350
set -eo pipefail
347351
git -C build/gh-pages add .
348-
git -C build/gh-pages -c user.name="Spock Framework Robot" -c user.email="dev@forum.spockframework.org" commit -qm "Publish docs/$variantLessVersion"
349-
git -C build/gh-pages push "https://\$GITHUB_TOKEN@github.com/spockframework/spock.git" gh-pages 2>&1 | sed "s/\$GITHUB_TOKEN/xxx/g"
352+
if git -C build/gh-pages diff --cached --quiet; then
353+
echo "No docs changes to publish for $variantLessVersion"
354+
else
355+
git -C build/gh-pages -c user.name="Spock Framework Robot" -c user.email="dev@forum.spockframework.org" commit -qm "Publish docs/$variantLessVersion"
356+
git -C build/gh-pages push "https://\$GITHUB_TOKEN@github.com/spockframework/spock.git" gh-pages 2>&1 | sed "s/\$GITHUB_TOKEN/xxx/g"
357+
fi
350358
git worktree remove --force build/gh-pages
351359
"""
352360
}

0 commit comments

Comments
 (0)