1
+ #! /bin/bash
2
+ set -e # Exit with nonzero exit code if anything fails
3
+
4
+ SOURCE_BRANCH=" develop"
5
+ TARGET_BRANCH=" gh-pages"
6
+
7
+ function doCompile {
8
+ . docker/build-mdbook
9
+ }
10
+
11
+ # Pull requests and commits to other branches shouldn't build
12
+ # if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
13
+ # exit 0
14
+ # fi
15
+
16
+ # Save some useful information
17
+ REPO=` git config remote.origin.url`
18
+ SSH_REPO=${REPO/ https: \/\/ github.com\/ / git@ github.com: }
19
+ SHA=` git rev-parse --verify HEAD`
20
+
21
+ # Clone the existing gh-pages for this repo into doc/holochain_101/book
22
+ git clone $REPO doc/holochain_101/book
23
+ cd doc/holochain_101/book
24
+ # Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
25
+ git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
26
+ cd ../../..
27
+
28
+ # Clean out existing contents
29
+ rm -rf doc/holochain_101/book/** /* || exit 0
30
+
31
+ # Run our compile script
32
+ doCompile
33
+
34
+ # Move a copy of our Github Pages config file back into the directory
35
+ cp _config.yml doc/holochain_101/book/_config.yml
36
+
37
+ # Set things up with git for committing new changes to the mdbook
38
+ cd doc/holochain_101/book
39
+ git config user.name " Travis CI"
40
+ git config user.email " $COMMIT_AUTHOR_EMAIL "
41
+
42
+ # If there are no changes to the compiled out (e.g. this is a README update) then just bail.
43
+ if git diff --quiet; then
44
+ echo " No changes to the output on this push; exiting."
45
+ exit 0
46
+ fi
47
+
48
+ # Commit the "changes", i.e. the new version.
49
+ # The delta will show diffs between new and old versions.
50
+ git add -A .
51
+ git commit -m " Deploy to GitHub Pages: ${SHA} "
52
+
53
+ # Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
54
+ # ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
55
+ # ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
56
+ # ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
57
+ # ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
58
+ # openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in ../deploy_key.enc -out ../deploy_key -d
59
+ # chmod 600 ../deploy_key
60
+ # eval `ssh-agent -s`
61
+ # ssh-add deploy_key
62
+
63
+ # Now that we're all set up, we can push.
64
+ git push $SSH_REPO $TARGET_BRANCH
0 commit comments