-
Save travis-scripts
as a devDependency
to package.json
:
$ npm install travis-scripts --save-dev
-
Generate a GitHub application token
for command-line use. See GitHub’s documentation
for more info.
-
Install the Travis client
and run:
$ travis encrypt -r "<username>/<repository>" \
GH_TOKEN="<your_github_access_token>" \
GH_USER_EMAIL="<your_email>" \
GH_USER_NAME="<your_name>" \
--add env.global
This adds an entry to your .travis.yml
file:
env:
global:
- secure: "<secure_key>"
-
Specify the commands to be run in .travis.yml
.
Here’s an example that runs npm install && npm run build
against the master
branch whenever Travis CI completes a run,
after which the resulting build
directory gets deployed to
the gh-pages
branch:
after_success:
- $(npm bin)/update-branch --commands "npm install && npm run build"
--commit-message "Hey GitHub, this content is for you! [skip ci]"
--directory "build"
--distribution-branch "gh-pages"
--source-branch "master"