1 | #!/bin/bash
|
2 |
|
3 |
|
4 | set -e
|
5 |
|
6 | if [ "$TRAVIS_BRANCH" != "master" -o -n "$TRAVIS_TAG" -o "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
7 | echo -e "Not building for a non master branch push - building without deploying."
|
8 | npm run docs
|
9 | exit 0
|
10 | fi
|
11 |
|
12 | echo -e "Building for a master branch push - building and deploying."
|
13 |
|
14 | REPO=$(git config remote.origin.url)
|
15 | SHA=$(git rev-parse --verify HEAD)
|
16 |
|
17 | TARGET_BRANCH="gh-pages"
|
18 | git clone $REPO dist -b $TARGET_BRANCH
|
19 |
|
20 | npm run docs
|
21 |
|
22 | rsync -vau docs/ dist/
|
23 |
|
24 | cd dist
|
25 | git add --all .
|
26 | git config user.name "Travis CI"
|
27 | git config user.email "${COMMIT_EMAIL}"
|
28 | git commit -m "Docs build: ${SHA}" || true
|
29 | git push "https://${GH_TOKEN}@${GH_REF}" $TARGET_BRANCH
|