Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Setup GitHub Deploy Keys For Travis

Setup Travis Deploy (macOS)

gem install travis

ssh-keygen -t rsa -b 4096 -f 'github_deploy_key' -N ''

cat github_deploy_key.pub | pbcopy

set public key as deploy key on github e.g https://github.com/USER/REPO/settings/keys

rm 'github_deploy_key.pub'

travis login --org --auto

travis encrypt-file 'github_deploy_key'

rm 'github_deploy_key'

git add 'github_deploy_key.enc'

add openssl line to before_install stage in your .travis.yml e.g.

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

git add '.travis.yml'

git commit -m 'chore: add github deploy key'

git push

@Regenhardt

This comment has been minimized.

Copy link

Regenhardt commented Mar 6, 2019

I tried this on windows 10, haven't got gem or pbcopy. WSL didnn't work either. What do I need here? Linux? Some other application I haven't got?

@pablen

This comment has been minimized.

Copy link

pablen commented Mar 21, 2019

@Regenhardt, follow these instructions to install Travis CLI https://github.com/travis-ci/travis.rb#windows
Regarding pbcopy, it's just to copy the key to your clipboard, you can omit it and copy it by hand.

@betteridiot

This comment has been minimized.

Copy link

betteridiot commented Aug 23, 2019

For the sake of posterity, users that are on a Windows Subsystem for Linux (WSL), you can use cat <filename> | clip.exe to copy to clipboard

@sodacrackers

This comment has been minimized.

Copy link

sodacrackers commented Oct 23, 2019

What is encrypted_xxxxxxxxxxxx_key and where does it come from?

@qoomon

This comment has been minimized.

Copy link
Owner Author

qoomon commented Oct 23, 2019

@sodacrackers you will find the xxxxxxxxxxxx value within the output of travis encrypt-file 'github_deploy_key'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.