Sha256: ba2832249415b32ea713ba03d8e8feeb9d7238c14a309a04f94c3a3c62b4eb84
Contents?: true
Size: 1.83 KB
Versions: 34
Compression:
Stored size: 1.83 KB
Contents
require 'json' require 'shellwords' module DPL class Provider module Heroku class API < Generic def push_app pack_archive upload_archive trigger_build end def archive_file Shellwords.escape("#{context.env['HOME']}/.dpl.#{option(:app)}.tgz") end def pack_archive log "creating application archive" context.shell "tar -zcf #{archive_file} ." end def upload_archive log "uploading application archive" context.shell "curl #{Shellwords.escape(put_url)} -X PUT -H 'Content-Type:' --data-binary @#{archive_file}" end def trigger_build log "triggering new deployment" response = post(:builds, source_blob: { url: get_url, version: version }) stream_url = response.fetch('stream_url') context.shell "curl #{Shellwords.escape(stream_url)}" end def get_url source_blob.fetch("get_url") end def put_url source_blob.fetch("put_url") end def source_blob @source_blog ||= post(:sources).fetch("source_blob") end def version @version ||= options[:version] || context.env['TRAVIS_COMMIT'] || `git rev-parse HEAD`.strip end def post(subpath, body = nil, options = {}) options = { method: :post, path: "/apps/#{option(:app)}/#{subpath}", headers: { "Accept" => "application/vnd.heroku+json; version=edge" }, expects: [200, 201] }.merge(options) if body options[:body] = JSON.dump(body) options[:headers]['Content-Type'] = 'application/json' end api.request(options).body end end end end end
Version data entries
34 entries across 34 versions & 1 rubygems