How to implement Travis CI to a Hugo site

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? Sign in Travis in https://travis-ci.org/ using github account. Enable Source github repo in Travis setting, eg.kencho51/gigathing Create Personal access token in github, the scopes include: repo admin:public_key admin:repo_hook user Copy the token generated and update the Travis Environment Variables as below: GH_TOKEN: paste the github GITHUB_EMAIL: [email protected] GITHUB_USERNAME: kencho51 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: [email protected] name: kencho51 repo: kencho51/kencho51.github.io verbose: true on: branch: master Insert build status into default template, every post will have build status on it. Markdown format: [![Build Status](https://travis-ci.org/kencho51/gigathing.svg?branch=master)](https://travis-ci.org/kencho51/gigathing) Image URL: https://travis-ci.org/kencho51/gigathing.svg?branch=master Reference Using Hugo and Travis CI To Deploy Blog To Github Pages Automatically Two ways to deploy a public GitHub Pages site from a private Hugo repository DEPLOY HUGO TO GITHUB PAGES AND BUILD WITH TRAVIS CI 使用 Travis CI 部署 Hugo 博客到 Github Pages Deploy Hugo from Gitlab CI to Github Pages How I use Travis CI to automatically deploy this blog to GitHub Pages How to deploy Hugo site minimally ...

July 23, 2020 · 2 min · 244 words · Ken Cho