This setup will deploy content from a
dist/ folder to GH-Pages via Travis-CI.
Create or use one of your existing repositories on GitHub. Clone it, and create a
master branch if you don’t already have one. Use this branch for the rest of the setup.
Initialize your project
In the root of your project, initialize with
npm init -f to create a default
package.json file if you don’t already have one. Edit it, add the
build script seen below to generate dummy output into a
Create a file called
deploy-to-gh-pages.sh containing this (replace
Travis setup script
Create a file called
.travis.yml containing this:
GitHub access token
Generate a new access token from GitHub. Give it a description, and the following permissions found here. Don’t close the window after you’ve created your token, you’ll need the token later in this setup.
Install Travis command line client
Install Travis Command Line Client with
gem install travis.
With the terminal, go into your project and execute the following (replace the text marked with bold):
travis encrypt -r YOUR-GITHUB-USERNAME/YOUR-GITHUB-REPOSITORY-NAME GITHUB_TOKEN=YOUR-GITHUB-TOKEN-HERE --add
This will add the encrypted token to your
Add your GitHub repository in your Travis CI repository overview.
GitHub repository settings
Go to your GitHub repository, under settings go to
Integration & Services. Click the
Add service dropdown and find
User, type your GitHub username.
Token, add your GitHub token.
- Under Domain, type
Create a folder in the root of your project called
dist. Inside it, add a file called
index.html containing some basic HTML. This is only for testing purpose, later you can add Gulp, Webpack or similar to generate your distribution content for this folder. Right now it’s the
build script from
package.js that generates content in the
In your GitHub repository, create a branch called
Push your changes to GitHub
Now commit and push your changes to the
master branch to GitHub. Travis-CI will detect this, and start deploying the content of the
dist folder to GH-Pages. After deployment your page is available at: