├── Gemfile ├── scripts ├── build.sh └── deploy.sh ├── .travis.yml ├── _config_ci.yml ├── LICENSE └── README.md /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "jekyll" 4 | gem "html-proofer" 5 | gem "jekyll-sitemap" -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | jekyll build --config _config_ci.yml 4 | htmlproofer ./_site --url-ignore www.youtube.com 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.1 4 | 5 | install: gem install jekyll html-proofer jekyll-sitemap 6 | script: scripts/build.sh 7 | 8 | # branch whitelist 9 | branches: 10 | only: 11 | - gh-pages # test the gh-pages branch 12 | - /pages-(.*)/ # test every branch which starts with "pages-" 13 | 14 | env: 15 | global: 16 | - NOKOGIRI_USE_SYSTEM_LIBRARIES=true # speeds up installation of html-proofer 17 | 18 | deploy: 19 | skip_cleanup: true 20 | provider: script 21 | script: scripts/deploy.sh 22 | on: 23 | branch: gh-pages -------------------------------------------------------------------------------- /scripts/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ $TRAVIS_BRANCH == 'gh-pages' ]] ; then 4 | cd _site 5 | git init 6 | 7 | git config user.name "Travis CI" 8 | git config user.email "feriese@microsoft.com" 9 | 10 | git add . 11 | git commit -m "Deploy" 12 | 13 | # We redirect any output to 14 | # /dev/null to hide any sensitive credential data that might otherwise be exposed. 15 | git push --force --quiet "https://${git_user}:${git_password}@${git_target}" master:master > /dev/null 2>&1 16 | else 17 | echo 'Invalid branch. You can only deploy from gh-pages.' 18 | exit 1 19 | fi -------------------------------------------------------------------------------- /_config_ci.yml: -------------------------------------------------------------------------------- 1 | # Site settings 2 | title: Partner Catalyst Team Case Studies 3 | email: sarasp@outlook.com 4 | description: > # this means to ignore newlines until "baseurl:" 5 | testbed for case study publication 6 | url: http://partnercatalyst.azurewebsites.net" # the base hostname & protocol for your site 7 | twitter_username: saraspalding 8 | github_username: catalystcode 9 | encoding: utf-8 10 | 11 | # Build settings 12 | # markdown: redcarpet 13 | # highlighter: pygments 14 | # extensions: [tables fenced_code_blocks] 15 | 16 | exclude: [vendor] 17 | kramdown: 18 | input: GFM 19 | gems: 20 | - jekyll-sitemap -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Felix Rieseberg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Deploy Jekyll pages using Git and Travis CI 2 | 3 | GitHub Pages are an amazing way to host Jekyll pages, but in some cases, you might be interested in running your Jekyll page on a different host (like Azure Web Apps, Heroku, AWS). Since the magic of Jekyll is that it generates static websites, I did not want to run a full Ruby server. Instead, I'm using Travis CI to setup a devops build pipeline, taking new commits, testing the page, and deploying it. Here's the workflow: 4 | 5 | * Create a new commit, triggering Travis CI 6 | * Install Ruby, Jekyll, HTMLProofer, and all dependencies 7 | * Compile the page 8 | * Test that all images and links work (using HTMLProofer) 9 | * If the test passed, enter the generated `_site` directory and create a new empty Git repository 10 | * Add and commit all static files 11 | * Force-push the result to a desired remote Git repo, suppressing any potentially compromising log messages 12 | 13 | The files of interest here are `.travis.yml`, `_config_ci.yml`, `scripts/build.sh` and `scripts/deploy.sh`. The Travis configuration file instructs Travis, to build, test, and deploy using `_config_ci.yml` as Jekyll configuration and `scripts/deploy.sh` as the custom deployment provider. 14 | 15 | To use this for your own project, update `.travis.yml` with your own white- and blacklisted branches. Then, check `build.sh` and ensure that the settings for `jekyll build` and HTMLProofer are fit for your site (in most cases, they should be). Finally, go to your Travis Profile to edit the settings for your source repository. In there, add three environment variables: 16 | 17 | * `git_user` Git username 18 | * `git_password` Git password 19 | * `git_target` Git target repository url (without `https://`) 20 | 21 | Include the four files in this repo in your source repo - and you're good to go! 22 | 23 | ## License 24 | MIT, please see LICENSE for details. --------------------------------------------------------------------------------