lib/stackdeploy.rb in stackdeploy-0.2.0 vs lib/stackdeploy.rb in stackdeploy-0.3.0

- old
+ new

@@ -1,15 +1,20 @@ require "stackdeploy/version" +require "net/http" +require "uri" require "aws-sdk" require "pp" module Stackdeploy def self.run region = ARGV[0] stack_name = ARGV[1] param_name = ARGV[2] param_value = ARGV[3] + sentry_org = ARGV[4] + sentry_app = ARGV[5] + git_sha = ARGV[6] if !region || !stack_name || !param_name || !param_value puts "Usage: stackdeploy region stack param value" exit(1) end @@ -60,8 +65,34 @@ if response.successful? puts "Update requested successfully." else puts "Update request failed." exit(1) + end + + # Notify sentry of the release + if sentry_org && sentry_app && git_sha + if !ENV['SENTRY_API_TOKEN'] + puts "Set SENTRY_API_TOKEN to update Sentry." + exit(1) + end + + uri = URI("https://app.getsentry.com/api/0/projects/#{sentry_org}/#{sentry_app}/releases/") + Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| + request = Net::HTTP::Post.new(uri) + request.form_data = { + version: param_value, + ref: git_sha + } + request["Authorization"] = "Bearer #{ENV["SENTRY_API_TOKEN"]}" + + response = http.request(request) + + if response.is_a?(Net::HTTPSuccess) + puts "Tagged release #{param_value} for revision #{git_sha}" + else + puts "Tagging release failed: #{response.body}" + end + end end end end