Sha256: ec3f77723244a5e2f8860b1a5a75a896de43e3effa2e4c7988f17b30765046ac
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
# generate and install ssh public key into deploy keys # add repo to known hosts # clone repo class Bard::Provision::Repo < Bard::Provision 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 def ssh_keypair? provision_server.run "[ -f ~/.ssh/id_rsa.pub ]", home: true, quiet: true end def already_cloned? provision_server.run "[ -d ~/#{project_name}/.git ]", home: true, quiet: true end 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", "git ls-remote #{github_url}", ].join("; "), home: true end def project_name server.project_name end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bard-1.0.0 | lib/bard/provision/repo.rb |