diff --git a/.travis.yml b/.travis.yml index 3630de989..74cb5db78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,5 +22,5 @@ script: jobs: include: - stage: Publish docs - if: type = push AND fork = false AND tag IS blank AND branch = master + if: type = push AND fork = false AND tag IS blank AND !(branch =~ /^dependabot\//) script: lerna bootstrap && lerna run build && scripts/travis/publishDocs.sh diff --git a/scripts/travis/publishDocs.sh b/scripts/travis/publishDocs.sh index 9eb6f9892..3bfa063d7 100755 --- a/scripts/travis/publishDocs.sh +++ b/scripts/travis/publishDocs.sh @@ -1,14 +1,28 @@ #!/bin/bash set -e +shopt -s extglob REPO_USER="${TRAVIS_REPO_SLUG%/*}" -npm run docs -- --base-url "/" +if [[ $TRAVIS_BRANCH = "master" ]]; then + BASE_URL="/" +else + BASE_URL="/branches/${TRAVIS_BRANCH}/" +fi + +npm run docs -- --base-url "${BASE_URL}" git clone "https://${GH_TOKEN}@github.com/${REPO_USER}/${REPO_USER}.github.io.git" docRepo -rm -rfv docRepo/* -mv -fv generatedDocs/* docRepo/ + +if [[ $TRAVIS_BRANCH = "master" ]]; then + GLOBIGNORE="branches" rm -rfv docRepo/* + mv -fv generatedDocs/* docRepo/ +else + rm -rfv docRepo/branches/"${TRAVIS_BRANCH}"/* + mkdir -pv "docRepo/branches/${TRAVIS_BRANCH}" + mv -fv generatedDocs/* "docRepo/branches/${TRAVIS_BRANCH}" +fi cd docRepo @@ -17,6 +31,6 @@ git config user.name "Travis CI" if [[ $(git status --porcelain) ]]; then git add . - git commit -m "Travis build: ${TRAVIS_BUILD_NUMBER}" + git commit -m "Travis build ${TRAVIS_BUILD_NUMBER}, branch ${TRAVIS_BRANCH}" git push --quiet --set-upstream origin master fi