Class: Slugforge::Commands::Deploy

Inherits:
SubCommand show all
Defined in:
lib/slugforge/commands/deploy.rb

Instance Method Summary collapse

Methods inherited from SubCommand

banner

Methods inherited from Slugforge::Command

#initialize, start

Methods included from Helper

included

Constructor Details

This class inherits a constructor from Slugforge::Command

Instance Method Details

#file(filename, *hosts) ⇒ Object



34
35
36
37
38
39
# File 'lib/slugforge/commands/deploy.rb', line 34

def file(filename, *hosts)
  logger.say_status :deploy, "deploying local slug #{filename}", :green
  slug_name = File.basename(filename)

  deploy(hosts, slug_name, deploy_options(:copy_type => :scp, :filename => filename))
end

#name(name_part, *hosts) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/slugforge/commands/deploy.rb', line 42

def name(name_part, *hosts)
  slug = find_slug(name_part)
  slug_name = File.basename(slug.key)
  logger.say_status :deploy, "deploying slug #{slug_name} from s3", :green

  url = expiring_url(slug)
  deploy(hosts, slug_name, deploy_options(:copy_type => :aws_cmd, :url => url, :aws_session => aws_session, :s3_url => "s3://#{aws_bucket}/#{slug.key}"))
end

#rollback(tag, *hosts) ⇒ Object

Raises:

  • (error_class)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/slugforge/commands/deploy.rb', line 52

def rollback(tag, *hosts)
  raise error_class, "There is no project found named '#{project_name}'. Try setting the project name with --project" unless tag_manager.projects.include?(project_name)
  data = tag_manager.rollback_slug_for_tag(project_name, tag)
  if data.nil?
    raise error_class, "could not find tag '#{tag}' for project '#{project_name}'"
  else
    logger.say_status :deploy, "deploying slug #{data}", :green
    slug = find_slug(data)
    slug_name = File.basename(data)
    url = expiring_url(slug)
  end

  raise error_class, "could not determine URL for tag" unless url
  deploy(hosts, slug_name, deploy_options(:copy_type => :aws_cmd, :url => url, :aws_session => aws_session, :s3_url => "s3://#{aws_bucket}/#{data}"))
end

#ssh(*hosts) ⇒ Object



87
88
89
# File 'lib/slugforge/commands/deploy.rb', line 87

def ssh(*hosts)
  deploy hosts, nil, deploy_options(:copy_type => :ssh)
end

#tag(tag, *hosts) ⇒ Object

Raises:

  • (error_class)


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/slugforge/commands/deploy.rb', line 69

def tag(tag, *hosts)
  raise error_class, "There is no project found named '#{project_name}'. Try setting the project name with --project" unless tag_manager.projects.include?(project_name)
  data = tag_manager.slug_for_tag(project_name, tag)
  if data.nil?
    raise error_class, "could not find tag '#{tag}' for project '#{project_name}'"
  else
    logger.say_status :deploy, "deploying slug #{data}", :green
    slug = find_slug(data)
    slug_name = File.basename(data)
    url = expiring_url(slug)
  end

  raise error_class, "could not determine URL for tag" unless url

  deploy(hosts, slug_name, deploy_options(:copy_type => :aws_cmd, :url => url, :aws_session => aws_session, :s3_url => "s3://#{aws_bucket}/#{data}"))
end