Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time

Continuous deployment to GitHub Pages

Turned out Travis CI can deploy static websites to GitHub Pages without any hassle. Luckily to me, I’d already been using a Makefile to build this website, so it took a few minutes to set it all up.

First, I had to generate a new access token for Travis CI with the public_repo scope and hand it to Travis as a secret variable named GITHUB_TOKEN in the repository settings.

Then, I created .travis.yml file:

language: node_js
- stable

  submodules: false

script: make build

  provider: pages
  skip-cleanup: true
  github-token: $GITHUB_TOKEN
  keep-history: true
  local-dir: static
    branch: master

It commands Travis to execute make build to build the website. If it goes well, the Makefile creates the static directory (see local-dir option) with the contents of the website. Then Travis checks if the current branch is master and uploads the contents of local-dir to target-branch (defaults to gh-pages).

That was it. Now I can edit files directly on (you can also) and any changes made there will get deployed in a matter of minutes.