I wanted to setup an automated deployment to GitHub Pages using Travis CI. What I found on existing documentation is the guide Auto-deploying built products to gh-pages with Travis by Domenic Denicola and the guide GitHub Pages Deployment by Travis CI. I didn’t like the lengthy deploy script of the former, nor the need to setup a personal access token on GitHub for a project belonging to an organization (giving Travis access to all my repositories).

I ended up using:

an SSH key added to the GitHub as deploy key the SSH private key committed to the repository using Travis’ encryption a custom script deployment on Travis the npm package gh-pages for committing and pushing the assets

Here’s the Travis configuration file I ended up with (4 lines for the SSH key, 6 lines for the deployment):

Finally, every push to the master branch is automatically tested, built and the resulting assets are committed+pushed to gh-pages. Are you aware of an even simpler setup? — please let me know!