Skip to content

Commit

Permalink
Continuous deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Gurnell committed Oct 11, 2018
1 parent c310d7e commit 7fee01f
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 25 deletions.
21 changes: 21 additions & 0 deletions .travis.yml
@@ -0,0 +1,21 @@
sudo: required
services:
- docker
language: scala
scala:
- 2.12.2
cache:
directories:
- "$HOME/.ivy2/cache"
- "$HOME/.sbt/boot"
- "$HOME/.cache/.coursier"
script:
- sudo mkdir .sbt
- sudo mkdir dist
- docker-compose run book npm install
- docker-compose run book ./sbt.sh pdf html epub ; export SBT_RESULT=$?
- test "$SBT_RESULT" == "0"
after_success:
- openssl aes-256-cbc -K $encrypted_7c1eda14b5fd_key -iv $encrypted_7c1eda14b5fd_iv
-in book_deploy_rsa.enc -out book_deploy_rsa -d
- "./book_deploy.sh"
25 changes: 0 additions & 25 deletions advanced-scala.sublime-project

This file was deleted.

51 changes: 51 additions & 0 deletions book-deploy.sh
@@ -0,0 +1,51 @@
#!/bin/bash
#
# Deploy the PDF, HTML, EPUB files of an Underscore book (source)
# into another Git repository (target)
#
set -e

# Configuration
# 1. The key for writing into the other repository.
# This is committed to the repo, encrypted by Travis,
# with filename extension '.enc'.
export KEY_FILENAME="book_deploy_rsa"
# 2. The branch we deploy from.
# Only deploy for non-PR commits to this branch.
export DEPLOY_BRANCH="feature/cd"
# 3. Folder inside target of where to place the artifacts:
export TARGET_DIR=books/scala-with-cats/
# 4. Commit message prefix (for the "books" repository)
export COMMIT_PREFIX="deploy scala withcats via travis"
# End of configuration

if [[ "${TRAVIS_PULL_REQUEST}" == "false" && "${TRAVIS_BRANCH}" == "${DEPLOY_BRANCH}" ]]; then
echo "Starting deploy to Github Pages"
mkdir -p "~/.ssh"
echo -e "Host github.com\n\tStrictHostKeyChecking no\nIdentityFile ~/.ssh/${KEY_FILENAME}\n" >> ~/.ssh/config
cp ${KEY_FILENAME} ~/.ssh/${KEY_FILENAME}
chmod 600 ~/.ssh/${KEY_FILENAME}

git config --global user.email "hello@underscore.io"
git config --global user.name "Travis Build"

export SRC_DIR=`pwd` # e.g., /home/travis/build/underscoreio/insert-book-name-here

export TEMP_DIR=/tmp/dist
mkdir -p $TEMP_DIR
cd $TEMP_DIR
git clone git@github.com:underscoreio/books.git

mkdir -p $TARGET_DIR
cd $TARGET_DIR

cp $SRC_DIR/dist/*.pdf .
cp $SRC_DIR/dist/*.html .
cp $SRC_DIR/dist/*.epub .

git add .
git commit -m "$COMMIT_PREFIX $TRAVIS_JOB_NUMBER $TRAVIS_COMMIT [ci skip]"
git push git@github.com:underscoreio/books.git master:master

rm -rf $TEMP_DIR
fi
Binary file added book_deploy_rsa.enc
Binary file not shown.
1 change: 1 addition & 0 deletions docker-compose.yml
Expand Up @@ -5,3 +5,4 @@ services:
volumes:
- .:/source
- ~/.ivy2:/root/.ivy2
- ~/.cache/.coursier:/root/.cache/.coursier

0 comments on commit 7fee01f

Please sign in to comment.