Based on qoomon's Gist.
See the Travis documentation for more information.
These commands should be run on the root
of your project/repository.
Install Travis CLI locally:
gem install travis
or brew install travis
if on OSX
Generate a new SSH Key for GitHub access:
ssh-keygen -t rsa -b 4096 -f 'github_deploy_key' -N ''
Copy the contents of the public key and set as a deploy key on GitHub (example: https://github.com/<USER>/<REPOSITORY>/settings/keys)
cat github_deploy_key.pub
Login to Travis CLI
- if you want to use
travis-ci.com
instead of.org
, add--pro
to the command. See the travis cli docs for more details.
travis login --pro --auto
Encrypt the GitHub deploy key
- again, if you want to use
travis-ci.com
, add--pro
to the command. - this will add two keys on your Travis dashboard, which you will use below
$encrypted_xxxxxxxxxxxx_key
$encrypted_xxxxxxxxxxxx_iv
travis encrypt-file --pro 'github_deploy_key'
Add the encoded deploy key to the GitHub repository
git add 'github_deploy_key.enc'
Add openssl
line on your .travis.yml
- replace
$encrypted_xxxxxxxxxxxx_key
and$encrypted_xxxxxxxxxxxx_iv
with the output oftravis encrypt-file
- you can also do this automatically by running
travis encrypt-file --add
before_install:
- >-
openssl aes-256-cbc
-K $encrypted_xxxxxxxxxxxx_key
-iv $encrypted_xxxxxxxxxxxx_iv
-in github_deploy_key.enc
-out github_deploy_key
-d
- chmod 600 github_deploy_key
- eval $(ssh-agent -s)
- ssh-add github_deploy_key
Add the changes to .travis.yml
to Git and push a new commit
git add '.travis.yml'
git commit -m 'chore: add github deploy key'
git push