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
node_js:
- stable
git:
submodules: false
script: make build
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN
keep-history: true
local-dir: static
on:
branch: masterIt 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 GitHub.com (you can also) and any changes made there will get deployed in a matter of minutes.