1 | #!/bin/bash
|
2 | set -e
|
3 |
|
4 | SOURCE_BRANCH="master"
|
5 | TARGET_BRANCH="gh-pages"
|
6 |
|
7 | function doCompile {
|
8 | cd vue-examples
|
9 | npm install
|
10 | npm run build
|
11 | cd ..
|
12 | npm run docs
|
13 | cp -r site/website/build/multiple-select/* build
|
14 | }
|
15 |
|
16 |
|
17 | if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
|
18 | echo "Skipping deploy; just doing a build."
|
19 | doCompile
|
20 | exit 0
|
21 | fi
|
22 |
|
23 |
|
24 | REPO=`git config remote.origin.url`
|
25 | SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
|
26 | SHA=`git rev-parse --verify HEAD`
|
27 | OUT=build
|
28 |
|
29 |
|
30 |
|
31 | git clone $REPO $OUT
|
32 | cd $OUT
|
33 | git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
|
34 | cd ..
|
35 |
|
36 |
|
37 | rm -rf $OUT/**/* || exit 0
|
38 |
|
39 |
|
40 | doCompile
|
41 |
|
42 |
|
43 | cd $OUT
|
44 | git config user.name "Travis CI"
|
45 | git config user.email "$COMMIT_AUTHOR_EMAIL"
|
46 |
|
47 |
|
48 | if git diff --quiet; then
|
49 | echo "No changes to the output on this push; exiting."
|
50 | exit 0
|
51 | fi
|
52 |
|
53 |
|
54 | VERSION=`git log --format=%h | wc -l | xargs echo -n`
|
55 | find . -type f -exec sed -i "s/v=VERSION/v=$VERSION/g" {} \;
|
56 |
|
57 |
|
58 |
|
59 | git add -A .
|
60 | git commit -m "Deploy to GitHub Pages: ${SHA}"
|
61 |
|
62 |
|
63 | ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
|
64 | ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
|
65 | ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
|
66 | ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
|
67 | openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in ../deploy_key.enc -out ../deploy_key -d
|
68 | chmod 600 ../deploy_key
|
69 | eval `ssh-agent -s`
|
70 | ssh-add ../deploy_key
|
71 |
|
72 |
|
73 | git push $SSH_REPO $TARGET_BRANCH
|