Class: Hyrb::Tasks::Project::Bootstrap

Inherits:
Hyrb::Task
  • Object
show all
Defined in:
lib/hyrb/tasks/project/bootstrap.rb

Instance Attribute Summary

Attributes inherited from Hyrb::Task

#env, #pipeline

Instance Method Summary collapse

Methods inherited from Hyrb::Task

depends, #initialize, prompt, prompts, #run_before

Constructor Details

This class inherits a constructor from Hyrb::Task

Instance Method Details

#run(env) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/hyrb/tasks/project/bootstrap.rb', line 28

def run(env)
  prompt "Project title", env.project, :title, env.project.name.humanize
  prompt "Project description", env.project, :description

  if ! env.project.users.try(:any?) || yes?("Update users for this project?")
    invoke Developers::Download
    invoke Developers::AddToProject
  end

  if ! env.project.repo_name && yes?("Should the project have a Github repo?")
    invoke Github::CreateRepo
  end

  if ! env.project.github_team && yes?("Should the project have a Github team?")
    invoke Github::CreateProjectTeam
  end

  if env.project.github_team
    invoke Github::SyncProjectTeam
  end

  if ! env.project.room_name
    invoke Hipchat::CreateRoom if yes? "Should the project have a Hipchat room?"
  end

  if env.project.repo_name && env.project.room_name && ! env.project.has_hipchat_hook
    invoke CreateHipchatHook
  end

  if env.environment_name || yes?("Work on a project environment?")
    invoke Environment::Init

    if env.environment.host
      say "Sever for evironment exists: #{env.environment.host}", :yellow
    elsif yes?("Provision a server for this environment?")
      provisioners = {
        digital_ocean: Provision::DigitalOcean,
        rackspace: Provision::Rackspace,
      }

      provider_name = ask "Provider:", { limited_to: provisioners.keys.map(&:to_s) }
      invoke provisioners[provider_name.to_sym]
    end

    if ! env.environment.has_dns_record && yes?("Create a DNS record?")
      invoke Rackspace::CreateDNSRecord
    end

    invoke Environment::SetupExisting

    if yes? "Set up ansible for this environment?"
      invoke Ansible::CreatePlaybook
    end
  end

end