diff --git a/.travis.yml b/.travis.yml index 1072eb21..d2e6eb3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/scripts/travis-blog-update.sh b/scripts/travis-blog-update.sh index e82a9c78..9ff4f621 100644 --- a/scripts/travis-blog-update.sh +++ b/scripts/travis-blog-update.sh @@ -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 diff --git a/scripts/travis-build.sh b/scripts/travis-build.sh new file mode 100644 index 00000000..1135ed96 --- /dev/null +++ b/scripts/travis-build.sh @@ -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 ..