Class: Bard::Provision::Repo

Inherits:
Bard::Provision show all
Defined in:
lib/bard/provision/repo.rb

Overview

generate and install ssh public key into deploy keys add repo to known hosts clone repo

Instance Attribute Summary

Attributes inherited from Bard::Provision

#config, #ssh_url

Instance Method Summary collapse

Methods inherited from Bard::Provision

call

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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 [email protected]:botandrosedesign/#{project_name}", home: true
  end

  puts ""
end