Giter Site home page Giter Site logo

jsntn / travis-jekyll-git Goto Github PK

View Code? Open in Web Editor NEW

This project forked from felixrieseberg/travis-jekyll-git

0.0 2.0 1.0 31 KB

Deploy Jekyll pages on github gh-pages branch using Git and Travis CI

License: MIT License

Ruby 25.00% Shell 75.00%

travis-jekyll-git's Introduction

Deploy Jekyll pages using Git and Travis CI

I just cloned this from Felix Rieseberg's repo and did some modification based on my situation, you may check out my branch myVersion here for the deployment. Thanks for Felix's sharing!


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:

  • Create a new commit, triggering Travis CI
  • Install Ruby, Jekyll, HTMLProofer, and all dependencies
  • Compile the page
  • Test that all images and links work (using HTMLProofer)
  • If the test passed, enter the generated _site directory and create a new empty Git repository
  • Add and commit all static files
  • Force-push the result to a desired remote Git repo, suppressing any potentially compromising log messages

The files of interest here are .travis.yml, _config_ci.yml(I didn't use this _config_ci.yml in my project, as I just need to add exclude: [vendor] in my Jekyll _config.yml, which is easier for me.[reference]), _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.

You may just execute this command to exclude vendor in your _config.yml:

echo -e "\nexclude: [vendor]" >> _config.yml

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).

I only need Travis CI triggered when I build pushes, so I made my Travis CI's General Settings like this:

Finally, go to your Travis Profile to edit the settings for your source repository. In there, add three environment variables:

  • git_user Git username
  • git_password Git password
  • git_target Git target repository url (without https://)

I used six environment variables in my Travis CI Settings, and keep the Display value in build log this way:

Note: repo_url is the url address of your repo like github.com/JasonTian/travis-jekyll-git.git, make sure don't include https://, working_branch means the branch that your Travis CI is working on.

Include the related files here and put them in your source repo. overall,

  • General Settings in Travis CI
  • Environment Variables in Travis CI
  • Gemfile(Version information can be specified here according to Github Pages Dependency versions for better compatibility, check this Gemfile file for example.)
  • echo -e "\nexclude: [vendor]" >> _config.yml
  • .travis.yml
  • _scripts folder

And you're good to go!

License

MIT, please see LICENSE for details.

travis-jekyll-git's People

Contributors

jsntn avatar felixrieseberg avatar

Watchers

 avatar  avatar

Forkers

snowdj

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.