img

What is Travis?

  • Travis is a continuous integration testing tool that integrates with GitHub.
  • It allows you to run automated tests on your code each time a commit is made to the repository.

How?

  1. Sign in Travis in https://travis-ci.org/ using github account.
  2. Enable Source github repo in Travis setting, eg.kencho51/gigathing
  3. Create Personal access token in github, the scopes include:
    • repo
    • admin:public_key
    • admin:repo_hook
    • user
  4. Copy the token generated and update the Travis Environment Variables as below:
  5. Create .travis.yml at the directoyy top level
language: go
dist: xenial
env:
  - HUGO_VERSION="0.74.2"
before_install:
  - sudo apt-get update -qq
install: true
before_script:
  - wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.deb
  - sudo dpkg -i hugo_${HUGO_VERSION}_Linux-64bit.deb
  - rm -rf public || exit 0
script:
  - hugo --gc -v --minify
deploy:
  provider: pages
  skip_cleanup: true
  keep_history: true
  github_token: $GH_TOKEN
  local_dir: public
  target_branch: master
  email: kencho.gigascience@gmail.com
  name: kencho51
  repo: kencho51/kencho51.github.io
  verbose: true
  on:
    branch: master
  1. Insert build status into default template, every post will have build status on it.

Reference

  1. Using Hugo and Travis CI To Deploy Blog To Github Pages Automatically
  2. Two ways to deploy a public GitHub Pages site from a private Hugo repository
  3. DEPLOY HUGO TO GITHUB PAGES AND BUILD WITH TRAVIS CI
  4. 使用 Travis CI 部署 Hugo 博客到 Github Pages
  5. Deploy Hugo from Gitlab CI to Github Pages
  6. How I use Travis CI to automatically deploy this blog to GitHub Pages
  7. How to deploy Hugo site minimally

Build Status