Skip to content

Instantly share code, notes, and snippets.

@DimitarNestorov
Forked from qoomon/TravisGitHub.md
Last active May 12, 2022 15:57
Show Gist options
  • Save DimitarNestorov/b09798fd81d8aba21e96e6460430f203 to your computer and use it in GitHub Desktop.
Save DimitarNestorov/b09798fd81d8aba21e96e6460430f203 to your computer and use it in GitHub Desktop.
Setup GitHub Deploy Keys For Travis

Setup Travis Deploy (macOS)

see Travis documentation

gem install travis

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

cat github_deploy_key.pub | pbcopy

Paste deploy key in https://github.com/<USER>/<REPOSITORY>/settings/keys

Create a personal access token here: https://github.com/settings/tokens

The scopes for the token are documented here: https://docs.travis-ci.com/user/github-oauth-scopes/

travis login --pro --debug --github-token ghp_yourtoken

travis encrypt-file 'github_deploy_key' --debug --pro --github-token ghp_yourtoken

git add 'github_deploy_key.enc'

Add openssl line to before_install stage in your .travis.yml

  • replace $encrypted_xxxxxxxxxxxx_key and $encrypted_xxxxxxxxxxxx_iv, see output of travis encrypt-file
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment