Class: DPL::Provider::Heroku::Anvil

Inherits:
Git show all
Defined in:
lib/dpl/provider/heroku/anvil.rb

Instance Attribute Summary

Attributes inherited from DPL::Provider

#context, #options

Instance Method Summary collapse

Methods inherited from Git

#check_app, #check_auth, #deploy, #remove_key, #restart, #run, #setup_key, #user

Methods inherited from DPL::Provider

#check_app, #cleanup, context, #create_key, #deploy, #error, experimental, #initialize, #log, new, npm_g, #option, pip, requires, #run, #setup_git_ssh, #sha, shell

Constructor Details

This class inherits a constructor from DPL::Provider

Instance Method Details

#apiObject

Raises:



9
10
11
12
# File 'lib/dpl/provider/heroku/anvil.rb', line 9

def api
  raise Error, 'anvil deploy strategy only works with api_key' unless options[:api_key]
  super
end

#needs_key?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/dpl/provider/heroku/anvil.rb', line 14

def needs_key?
  false
end

#push_appObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dpl/provider/heroku/anvil.rb', line 18

def push_app
  sha = ENV['TRAVIS_COMMIT'] || `git rev-parse HEAD`.strip
  response = Excon.post release_url,
    :body    => { "slug_url" => slug_url, "description" => "Deploy #{sha} via Travis CI" }.to_json,
    :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }

  print "\nDeploying slug "
  while response.status == 202
    location = response.headers['Location']
    response = Excon.get("https://:#{option(:api_key)}@cisaurus.heroku.com#{location}")
    sleep(1)
    print '.'
  end

  if response.status.between? 200, 299
    puts " success!"
  else
    raise Error, "deploy failed, anvil response: #{response.body}"
  end
end

#release_urlObject



47
48
49
# File 'lib/dpl/provider/heroku/anvil.rb', line 47

def release_url
  "https://:#{option(:api_key)}@cisaurus.heroku.com/v1/apps/#{option(:app)}/release"
end

#slug_urlObject



39
40
41
42
43
44
45
# File 'lib/dpl/provider/heroku/anvil.rb', line 39

def slug_url
  @slug_url ||= begin
    ::Anvil.headers["X-Heroku-User"] = user
    ::Anvil.headers["X-Heroku-App"]  = option(:app)
    ::Anvil::Engine.build "."
  end
end