Auto deploy commits from Travis to Github pages

Auto deploy from Travis to Github

  1. Create a key and save it to a file called deploy_rsa
    ssh-keygen -t rsa -b 4096 -C '' -f ./deploy_rsa

  2. Add the key, encrypted, to Travis
    travis encrypt-file deploy_rsa --add

  3. Add the encrypted key to git
    git add deploy_rsa.enc

  4. Go to the repository settings/deploy keys page on Github and add a new Deploy Key. Add the output of the following command + check Allow write

  5. Remove the actual key file so it won’t be commited to the repo by accident
    rm deploy_rsa

  6. Create a script:

  set -e
  # setup ssh-agent and provide the GitHub deploy key
  eval "$(ssh-agent -s)"
  chmod 600 deploy_rsa
  ssh-add deploy_rsa
  # This method depends on how you build your project.
  # This is a node.js example:
  # commit the assets in build/ to the gh-pages branch and push to GitHub using SSH
  ./node_modules/.bin/gh-pages -d dist/ -b gh-pages -r${TRAVIS_REPO_SLUG}.git
  1. Make the script runnable

chmod +x

  1. Call the script in your .travis.yml file
  - provider: script
    skip_cleanup: true
    script: "./"
      branch: master