Merge pull request #150 from phil-opp/travis_hugo

Build hugo blog using travis
This commit is contained in:
Philipp Oppermann
2016-05-01 15:12:58 +02:00
3 changed files with 42 additions and 10 deletions

View File

@@ -15,5 +15,11 @@ addons:
packages:
- nasm
script:
- make
install:
- export PATH=$HOME/.local/bin:$PATH
- pip install pygments --user
- pip install pygments-github-lexers --user
script: bash scripts/travis-build.sh
after_success: sh scripts/travis-blog-update.sh

View File

@@ -1,14 +1,12 @@
#!/bin/sh
# License: CC0 1.0 Universal
# https://creativecommons.org/publicdomain/zero/1.0/legalcode
set -e
# update blog if current branch is `master`
[ "$TRAVIS_BRANCH" = master ]
[ "$TRAVIS_PULL_REQUEST" = false ]
# decrypt ssh key
eval SSH_KEY_TRAVIS_ID=aaae456e27e9
eval key=\$encrypted_${SSH_KEY_TRAVIS_ID}_key
eval iv=\$encrypted_${SSH_KEY_TRAVIS_ID}_iv
@@ -17,13 +15,22 @@ mkdir -p ~/.ssh
openssl aes-256-cbc -K $key -iv $iv -in scripts/travis-blog_os.enc -out ~/.ssh/id_rsa -d
chmod 600 ~/.ssh/id_rsa
# clone gh-pages to `deploy_blog`
git clone --branch gh-pages git@github.com:$TRAVIS_REPO_SLUG deploy_blog
cd deploy_blog
# set git user/email
git config user.name "travis-update-bot"
git config user.email "travis-update-bot@phil-opp.com"
cp ../posts/* _posts/
cp ../pages/* ./
git add .
# update blog
rm -r *
cp -r ../hugo/public/* .
rm -r post post.html page page.html # remove per-category pages/feeds
# commit
git add --all .
git commit -qm "Update blog to $TRAVIS_COMMIT"
# push changes
git push -q origin gh-pages

19
scripts/travis-build.sh Normal file
View File

@@ -0,0 +1,19 @@
#!/bin/sh
set -e
# build rust project
make
# clone hugo branch, which contains the blog template
git clone --branch=hugo https://github.com/phil-opp/blog_os.git hugo
cd hugo
# download hugo
wget https://github.com/spf13/hugo/releases/download/v0.15/hugo_0.15_linux_amd64.tar.gz
tar xf hugo_0.15_linux_amd64.tar.gz
# build the blog
hugo_0.15_linux_amd64/hugo_0.15_linux_amd64
cd ..