Skip to content

Commit

Permalink
[ci] [docs] Improved detection for changes in documentation
Browse files Browse the repository at this point in the history
Now only updating docs on sourceforge, if there are changes
  • Loading branch information
adangel committed Jun 20, 2018
1 parent d3482ec commit a89d541
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .travis/build-coveralls.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
set -e

source .travis/common-functions.sh
source .travis/logger.sh
source .travis/common-functions.sh

VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1)
log_info "Building PMD Coveralls.io report ${VERSION} on branch ${TRAVIS_BRANCH}"
Expand Down
2 changes: 1 addition & 1 deletion .travis/build-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
set -e

source .travis/common-functions.sh
source .travis/logger.sh
source .travis/common-functions.sh

function push_docs() {
if git diff --quiet docs; then
Expand Down
16 changes: 2 additions & 14 deletions .travis/build-doc.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
set -e

source .travis/common-functions.sh
source .travis/logger.sh
source .travis/common-functions.sh

VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1)
log_info "Building PMD Documentation ${VERSION} on branch ${TRAVIS_BRANCH}"
Expand Down Expand Up @@ -41,7 +41,7 @@ zip -qr pmd-doc-${VERSION}.zip pmd-doc-${VERSION}/
fi

# rsync site to pmd.sourceforge.net/snapshot
if [[ "${VERSION}" == *-SNAPSHOT && "${TRAVIS_BRANCH}" == "master" ]]; then
if [[ "${VERSION}" == *-SNAPSHOT && "${TRAVIS_BRANCH}" == "master" ]] && has_docs_change; then
echo -e "\n\n"
log_info "Uploading snapshot site to pmd.sourceforge.net/snapshot..."
travis_wait rsync -ah --stats --delete pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/
Expand All @@ -57,18 +57,6 @@ zip -qr pmd-doc-${VERSION}.zip pmd-doc-${VERSION}/




has_docs_change() {
if [[ $(git diff --name-only ${TRAVIS_COMMIT_RANGE}) = *"docs/"* ]]; then
log_info "Checking for changes in docs/ (TRAVIS_COMMIT_RANGE=${TRAVIS_COMMIT_RANGE}): changes found"
return 0
else
log_info "Checking for changes in docs/ (TRAVIS_COMMIT_RANGE=${TRAVIS_COMMIT_RANGE}): no changes"
return 1
fi
}


#
# Push the generated site to gh-pages branch
#
Expand Down
2 changes: 1 addition & 1 deletion .travis/build-sonar.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
set -e

source .travis/common-functions.sh
source .travis/logger.sh
source .travis/common-functions.sh

VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1)
log_info "Building PMD Sonar ${VERSION} on branch ${TRAVIS_BRANCH}"
Expand Down
10 changes: 10 additions & 0 deletions .travis/common-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ function travis_isPush() {
return 1
fi
}

function has_docs_change() {
if [[ $(git diff --name-only ${TRAVIS_COMMIT_RANGE}) = *"docs/"* ]]; then
log_info "Checking for changes in docs/ (TRAVIS_COMMIT_RANGE=${TRAVIS_COMMIT_RANGE}): changes found"
return 0
else
log_info "Checking for changes in docs/ (TRAVIS_COMMIT_RANGE=${TRAVIS_COMMIT_RANGE}): no changes"
return 1
fi
}

0 comments on commit a89d541

Please sign in to comment.