First, add SURGE_USER and SURGE_TOKEN environment variables to the repo's settings page in Travis:
Then modify the repo's .travis.yml file to perform whatever build steps are required to generate the static website in the before_deploy step.
Below, I'm installing Jekyll and building the site in the docs/ dir where my site's source files live.
language: node_js
before_deploy:
- gem install jekyll
- cd ./docs/ && jekyll build
- REPO_SLUG=${TRAVIS_REPO_SLUG//\//-}
deploy:
provider: surge
project: ./docs/_site
domain: "${REPO_SLUG}-${TRAVIS_BRANCH}.surge.sh"
skip_cleanup: true
on:
all_branches: trueTravis will deploy every branch that is pushed up to GitHub with domains in the format https://<github-username>-<repo_name>-<branch-name>.surge.sh.
