class Bard::Provision::Repo
generate and install ssh public key into deploy keys add repo to known hosts clone repo
Public Instance Methods
call()
click to toggle source
# File lib/bard/provision/repo.rb, line 8 def call print "Repo:" if !already_cloned? if !can_clone_project? if !ssh_keypair? print " Generating keypair in ~/.ssh," provision_server.run! "ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa -q -N \"\"", home: true end print " Add public key to GitHub repo deploy keys," title = "#{server.ssh_uri.user}@#{server.ssh_uri.host}" key = provision_server.run "cat ~/.ssh/id_rsa.pub", home: true Bard::Github.new(server.project_name).add_deploy_key title:, key: end print " Cloning repo," provision_server.run! "git clone git@github.com:botandrosedesign/#{project_name}", home: true end puts " ✓" end
Private Instance Methods
already_cloned?()
click to toggle source
# File lib/bard/provision/repo.rb, line 34 def already_cloned? provision_server.run "[ -d ~/#{project_name}/.git ]", home: true, quiet: true end
can_clone_project?()
click to toggle source
# File lib/bard/provision/repo.rb, line 38 def can_clone_project? github_url = "git@github.com:botandrosedesign/#{project_name}" provision_server.run [ "needle=$(ssh-keyscan -t ed25519 github.com 2>/dev/null | cut -d \" \" -f 2-3)", "grep -q \"$needle\" ~/.ssh/known_hosts || ssh-keyscan -H github.com >> ~/.ssh/known_hosts 2>/dev/null", "git ls-remote #{github_url}", ].join("; "), home: true, quiet: true end
project_name()
click to toggle source
# File lib/bard/provision/repo.rb, line 47 def project_name server.project_name end
ssh_keypair?()
click to toggle source
# File lib/bard/provision/repo.rb, line 30 def ssh_keypair? provision_server.run "[ -f ~/.ssh/id_rsa.pub ]", home: true, quiet: true end