deploy.sh (2177B)
1 #!/bin/bash 2 set -e # Exit with nonzero exit code if anything fails 3 4 SOURCE_BRANCH="master" 5 TARGET_BRANCH="gh-pages" 6 7 function doCheck { 8 mkdir .out 9 node .scripts/convert.js --source=release-doc-in-process/all_vf.TTL --outDir=.out 10 } 11 12 function doGenerate { 13 node .scripts/convert.js --source=release-doc-in-process/all_vf.TTL --outDir=.out 14 } 15 16 # Pull requests and commits to other branches shouldn't try to deploy, just build to verify 17 if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then 18 echo "Skipping deploy; just doing vocab check." 19 doCheck 20 exit 0 21 fi 22 23 24 # Save some useful information 25 REPO=`git config remote.origin.url` 26 SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:} 27 SHA=`git rev-parse --verify HEAD` 28 29 # Clone the existing gh-pages for this repo into .out/ 30 # Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply) 31 git clone $REPO .out 32 cd .out 33 git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH 34 cd .. 35 36 # Clean out existing contents 37 rm -fr .out/vf.* || exit 0 38 #rm -fr .out/index.html || exit 0 39 #rm -fr .out/vowl-vf.json || exit 0 40 41 # Run generate script 42 doGenerate 43 ls .out 44 # cp .out/vf.html .out/index.html 45 # config the cloned repo 46 cd .out 47 git config user.name "Travis CI" 48 git config user.email "$COMMIT_AUTHOR_EMAIL" 49 50 # If there are no changes to the compiled out (e.g. this is a README update) then just bail. 51 if [ -z `git diff --exit-code` ]; then 52 echo "No changes to the output on this push; exiting." 53 exit 0 54 fi 55 56 # Commit the "changes", i.e. the new version. 57 # The delta will show diffs between new and old versions. 58 git add . 59 git commit -m "Deploy to GitHub Pages: ${SHA}" 60 61 # Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc 62 ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key" 63 ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv" 64 ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR} 65 ENCRYPTED_IV=${!ENCRYPTED_IV_VAR} 66 openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in id_rsa.enc -out id_rsa -d 67 chmod 600 id_rsa 68 eval `ssh-agent -s` 69 ssh-add id_rsa 70 71 # Now that we're all set up, we can push. 72 git push $SSH_REPO $TARGET_BRANCH