Class: DPL::Provider::Heroku::Anvil
- Inherits:
-
Git
show all
- Defined in:
- lib/dpl/provider/heroku/anvil.rb
Constant Summary
collapse
- HEROKU_BUILDPACKS =
['ruby', 'nodejs', 'clojure', 'python', 'java', 'gradle', 'grails', 'scala', 'play']
- HEROKU_BUILDPACK_PREFIX =
"https://github.com/heroku/heroku-buildpack-"
Instance Attribute Summary
#context, #options
Instance Method Summary
collapse
Methods inherited from Git
#git_url, #write_netrc
Methods inherited from Generic
#api_options, #check_app, #check_auth, #info, #needs_key?, #restart, #run, #user
apt_get, #check_app, #cleanup, #commit_msg, context, #create_key, #detect_encoding?, #encoding_for, #error, experimental, #initialize, #log, #needs_key?, new, npm_g, #option, pip, requires, #run, #setup_git_credentials, #setup_git_ssh, #sha, shell, #uncleanup, #user_agent, #warn
Constructor Details
This class inherits a constructor from DPL::Provider
Instance Method Details
#api ⇒ Object
11
12
13
14
|
# File 'lib/dpl/provider/heroku/anvil.rb', line 11
def api
raise Error, 'anvil deploy strategy only works with api_key' unless options[:api_key]
super
end
|
#deploy ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/dpl/provider/heroku/anvil.rb', line 16
def deploy
warn ''
if options[:strategy]
warn 'You have explicitly set your deploy strategy to %p.' % options[:strategy]
warn 'Anvil support will be dropped in the near future.'
warn 'Please consider changing it to "api" or "git".'
else
warn 'The default strategy for Heroku deployments is currently "anvil".'
warn 'This will be changed to "api" in the near future.'
warn 'Consider setting it explicitly to "api" or "git".'
end
warn ''
super
end
|
#push_app ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/dpl/provider/heroku/anvil.rb', line 32
def push_app
sha = context.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.['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_url ⇒ Object
66
67
68
|
# File 'lib/dpl/provider/heroku/anvil.rb', line 66
def release_url
"https://:#{option(:api_key)}@cisaurus.heroku.com/v1/apps/#{option(:app)}/release"
end
|
#slug_url ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/dpl/provider/heroku/anvil.rb', line 53
def slug_url
@slug_url ||= begin
::Anvil.["X-Heroku-User"] = user
::Anvil.["X-Heroku-App"] = option(:app)
if HEROKU_BUILDPACKS.include? options[:buildpack]
options[:buildpack] = HEROKU_BUILDPACK_PREFIX + options[:buildpack] + ".git"
end
::Anvil::Engine.build ".", :buildpack => options[:buildpack]
rescue ::Anvil::Builder::BuildError => e
raise Error, "deploy failed, anvil build error: #{e.message}"
end
end
|