def generate_key
github.with_basic_auth do |gh|
login = gh['user']['login']
check_access(gh)
empty_line
say "Generating RSA key."
private_key = Tools::SSLKey.generate_rsa
self.description ||= "key for fetching dependencies for #{slug} via #{login}"
say "Uploading public key to GitHub."
gh.post("/user/keys", :title => "#{description} (Travis CI)", :key => Tools::SSLKey.rsa_ssh(private_key.public_key))
say "Uploading private key to Travis CI."
ssh_key.update(:value => private_key.to_s, :description => description)
empty_line
say "You can store the private key to reuse it for other repositories (travis sshkey --upload FILE)."
if agree("Store private key? ") { |q| q.default = "no" }
path = ask("Path: ") { |q| q.default = "id_travis_rsa" }
File.write(path, private_key.to_s)
end
end
end