Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have Travis CI build static site from source files
- Loading branch information
1 parent
2031189
commit e9cca3a
Showing
5 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ Gemfile.lock | |
node_modules | ||
package.json | ||
.idea/ | ||
deploy_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
language: ruby | ||
branches: | ||
only: | ||
- source | ||
rvm: | ||
- 2.3.4 | ||
before_install: | ||
- openssl aes-256-cbc -K $encrypted_1dd176ece64a_key -iv $encrypted_1dd176ece64a_iv -in deploy_key.enc -out deploy_key -d | ||
before_script: | ||
- chmod +x ./deploy.sh | ||
script: bash ./deploy.sh | ||
exclude: | ||
- vendor | ||
sudo: false | ||
env: | ||
global: | ||
- COMMIT_AUTHOR_EMAIL: watir.team@gmail.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
# https://ayastreb.me/deploy-jekyll-to-github-pages-with-travis-ci/ | ||
# https://gist.github.com/domenic/ec8b0fc8ab45f39403dd | ||
|
||
set -e # Exit with nonzero exit code if anything fails | ||
|
||
SOURCE_BRANCH="source" | ||
TARGET_BRANCH="master" | ||
|
||
function doCompile { | ||
bundle exec jekyll build | ||
} | ||
|
||
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify | ||
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then | ||
echo "Skipping deploy; just doing a build." | ||
doCompile | ||
exit 0 | ||
fi | ||
|
||
# Save some useful information | ||
REPO=`git config remote.origin.url` | ||
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:} | ||
|
||
echo "Make sure source doesn't have _site data" | ||
rm -rf _site | ||
|
||
echo "Clone the existing code for this repo into _site/" | ||
git clone $REPO _site | ||
|
||
echo "Build content with Jekyll" | ||
doCompile | ||
|
||
echo "Set Git information" | ||
cd _site | ||
git config user.name "Travis CI" | ||
git config user.email "$COMMIT_AUTHOR_EMAIL" | ||
|
||
# If there are no changes to the compiled out (e.g. this is a README update) then just bail. | ||
if git diff --quiet -- . ':(exclude)*.xml'; then | ||
echo "No changes to the output on this push; exiting." | ||
exit 0 | ||
fi | ||
|
||
echo "Commit the changes" | ||
# The delta will show diffs between new and old versions. | ||
git add -A . | ||
git commit -m "Deploy Generated Content from Travis Build ${TRAVIS_BUILD_NUMBER}" | ||
|
||
echo "Set permissions for the Key" | ||
chmod 600 ../deploy_key | ||
|
||
echo "SSH Add key" | ||
eval `ssh-agent -s` | ||
ssh-add ../deploy_key | ||
|
||
echo "Push to Repo" | ||
git push $SSH_REPO |
Binary file not shown.