{"action":"created","comment":{"url":"https://api.github.com/repos/giftcardzen/deploy-script/pulls/comments/61171400","id":61171400,"diff_hunk":"@@ -0,0 +1,106 @@\n+require 'zen/deploy/version'\n+Gem.find_files('zen/deploy/steps/**.rb').each { |file| require file }\n+require 'zen/deploy/railtie' if defined?(Rails)\n+require 'zen/deploy/configuration'\n+require 'zen/deploy/slack_notifier'\n+require 'scriptster'\n+require 'slack-ruby-client'\n+require 'active_support'\n+require 'active_support/core_ext'\n+require 'yaml'\n+require 'pry'\n+require 'net/http'\n+\n+module Zen\n+  module Deploy\n+    class Deployer\n+      attr_reader :config, :slack_notifier, :yaml_config, :captured_steps\n+\n+      def initialize\n+        begin\n+          @yaml_config = YAML.load(IO.read('.zen-deploy.yml'))\n+        rescue Errno::ENOENT\n+          return fatal_error \"YAML configuration file couldn't be found.\"\n+        rescue Psych::SyntaxError => e\n+          return fatal_error \"YAML configuration file contains invalid syntax. #{e}\"\n+        end\n+\n+        @config = Configuration.build(yaml_config, self)\n+        ENV['TZ'] = config.time_zone\n+        ENV['RAILS_ENV'] = config.rails_environment\n+\n+        return if SlackNotifier.configuration_present?(config)\n+        Scriptster.log :info, 'Slack integration not enabled - not all configuration present.'\n+      end\n+\n+      # :reek:NestedIterators: { max_allowed_nesting: 3 }\n+      def run\n+        config.deployments.sort_by(&:order).each_with_index do |deployment, index|\n+          @captured_steps = {}.with_indifferent_access\n+          verify_steps(deployment.steps)\n+          if deployment.ensure.present?\n+            verify_steps(deployment.ensure)\n+            define_singleton_method 'run_ensure_steps' do\n+              run_ensure(deployment)\n+            end\n+          end\n+          log_debug \"Starting deployment of #{deployment[:app_name]} (#{index + 1} of #{config.deployments.size})\"\n+          run_deployment(deployment)\n+          log_debug \"Deployment of #{deployment[:app_name]} complete\"\n+        end\n+      end\n+\n+      def notify_slack(msg, color = '#ccc')\n+        @slack_notifier.notify(msg, color) if @slack_notifier.present?\n+      end\n+\n+      def fatal_error(msg)\n+        run_ensure_steps if defined?(run_ensure_steps)\n+        notify_slack \"_ERROR_: #{msg}\", 'danger'\n+        Scriptster.log :err, msg\n+        exit 1\n+      end\n+\n+      private\n+\n+      def run_deployment(deployment)\n+        run_steps(:steps, deployment)\n+      end\n+\n+      def run_ensure(deployment)\n+        run_steps(:ensure, deployment)\n+      end\n+\n+      def run_steps(group, deployment)\n+        deployment_config = OpenStruct.new(config.to_h.merge(deployment.to_h))\n+        @slack_notifier = SlackNotifier.new(deployment_config)","path":"lib/zen/deploy.rb","position":76,"original_position":76,"commit_id":"f0353c2bfb373e190cdd5f3576d77f9cd5e0e952","original_commit_id":"f0353c2bfb373e190cdd5f3576d77f9cd5e0e952","user":{"login":"gabrieljoelc","id":147849,"avatar_url":"https://avatars.githubusercontent.com/u/147849?v=3","gravatar_id":"","url":"https://api.github.com/users/gabrieljoelc","html_url":"https://github.com/gabrieljoelc","followers_url":"https://api.github.com/users/gabrieljoelc/followers","following_url":"https://api.github.com/users/gabrieljoelc/following{/other_user}","gists_url":"https://api.github.com/users/gabrieljoelc/gists{/gist_id}","starred_url":"https://api.github.com/users/gabrieljoelc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabrieljoelc/subscriptions","organizations_url":"https://api.github.com/users/gabrieljoelc/orgs","repos_url":"https://api.github.com/users/gabrieljoelc/repos","events_url":"https://api.github.com/users/gabrieljoelc/events{/privacy}","received_events_url":"https://api.github.com/users/gabrieljoelc/received_events","type":"User","site_admin":false},"body":"Make this a private getter/accessor","created_at":"2016-04-26T21:52:22Z","updated_at":"2016-04-26T21:52:22Z","html_url":"https://github.com/giftcardzen/deploy-script/pull/108#discussion_r61171400","pull_request_url":"https://api.github.com/repos/giftcardzen/deploy-script/pulls/108","_links":{"self":{"href":"https://api.github.com/repos/giftcardzen/deploy-script/pulls/comments/61171400"},"html":{"href":"https://github.com/giftcardzen/deploy-script/pull/108#discussion_r61171400"},"pull_request":{"href":"https://api.github.com/repos/giftcardzen/deploy-script/pulls/108"}}},"pull_request":{"url":"https://api.github.com/repos/giftcardzen/deploy-script/pulls/108","id":67963969,"html_url":"https://github.com/giftcardzen/deploy-script/pull/108","diff_url":"https://github.com/giftcardzen/deploy-script/pull/108.diff","patch_url":"https://github.com/giftcardzen/deploy-script/pull/108.patch","issue_url":"https://api.github.com/repos/giftcardzen/deploy-script/issues/108","number":108,"state":"open","locked":false,"title":"Feature/gemify","user":{"login":"gabrieljoelc","id":147849,"avatar_url":"https://avatars.githubusercontent.com/u/147849?v=3","gravatar_id":"","url":"https://api.github.com/users/gabrieljoelc","html_url":"https://github.com/gabrieljoelc","followers_url":"https://api.github.com/users/gabrieljoelc/followers","following_url":"https://api.github.com/users/gabrieljoelc/following{/other_user}","gists_url":"https://api.github.com/users/gabrieljoelc/gists{/gist_id}","starred_url":"https://api.github.com/users/gabrieljoelc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabrieljoelc/subscriptions","organizations_url":"https://api.github.com/users/gabrieljoelc/orgs","repos_url":"https://api.github.com/users/gabrieljoelc/repos","events_url":"https://api.github.com/users/gabrieljoelc/events{/privacy}","received_events_url":"https://api.github.com/users/gabrieljoelc/received_events","type":"User","site_admin":false},"body":"Closes #104 ","created_at":"2016-04-26T21:48:08Z","updated_at":"2016-04-26T21:52:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/giftcardzen/deploy-script/pulls/108/commits","review_comments_url":"https://api.github.com/repos/giftcardzen/deploy-script/pulls/108/comments","review_comment_url":"https://api.github.com/repos/giftcardzen/deploy-script/pulls/comments{/number}","comments_url":"https://api.github.com/repos/giftcardzen/deploy-script/issues/108/comments","statuses_url":"https://api.github.com/repos/giftcardzen/deploy-script/statuses/f0353c2bfb373e190cdd5f3576d77f9cd5e0e952","head":{"label":"giftcardzen:feature/gemify","ref":"feature/gemify","sha":"f0353c2bfb373e190cdd5f3576d77f9cd5e0e952","user":{"login":"giftcardzen","id":7176061,"avatar_url":"https://avatars.githubusercontent.com/u/7176061?v=3","gravatar_id":"","url":"https://api.github.com/users/giftcardzen","html_url":"https://github.com/giftcardzen","followers_url":"https://api.github.com/users/giftcardzen/followers","following_url":"https://api.github.com/users/giftcardzen/following{/other_user}","gists_url":"https://api.github.com/users/giftcardzen/gists{/gist_id}","starred_url":"https://api.github.com/users/giftcardzen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giftcardzen/subscriptions","organizations_url":"https://api.github.com/users/giftcardzen/orgs","repos_url":"https://api.github.com/users/giftcardzen/repos","events_url":"https://api.github.com/users/giftcardzen/events{/privacy}","received_events_url":"https://api.github.com/users/giftcardzen/received_events","type":"Organization","site_admin":false},"repo":{"id":33321198,"name":"deploy-script","full_name":"giftcardzen/deploy-script","owner":{"login":"giftcardzen","id":7176061,"avatar_url":"https://avatars.githubusercontent.com/u/7176061?v=3","gravatar_id":"","url":"https://api.github.com/users/giftcardzen","html_url":"https://github.com/giftcardzen","followers_url":"https://api.github.com/users/giftcardzen/followers","following_url":"https://api.github.com/users/giftcardzen/following{/other_user}","gists_url":"https://api.github.com/users/giftcardzen/gists{/gist_id}","starred_url":"https://api.github.com/users/giftcardzen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giftcardzen/subscriptions","organizations_url":"https://api.github.com/users/giftcardzen/orgs","repos_url":"https://api.github.com/users/giftcardzen/repos","events_url":"https://api.github.com/users/giftcardzen/events{/privacy}","received_events_url":"https://api.github.com/users/giftcardzen/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/giftcardzen/deploy-script","description":"Script for deploying Rails application from Codeship to Heroku","fork":false,"url":"https://api.github.com/repos/giftcardzen/deploy-script","forks_url":"https://api.github.com/repos/giftcardzen/deploy-script/forks","keys_url":"https://api.github.com/repos/giftcardzen/deploy-script/keys{/key_id}","collaborators_url":"https://api.github.com/repos/giftcardzen/deploy-script/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/giftcardzen/deploy-script/teams","hooks_url":"https://api.github.com/repos/giftcardzen/deploy-script/hooks","issue_events_url":"https://api.github.com/repos/giftcardzen/deploy-script/issues/events{/number}","events_url":"https://api.github.com/repos/giftcardzen/deploy-script/events","assignees_url":"https://api.github.com/repos/giftcardzen/deploy-script/assignees{/user}","branches_url":"https://api.github.com/repos/giftcardzen/deploy-script/branches{/branch}","tags_url":"https://api.github.com/repos/giftcardzen/deploy-script/tags","blobs_url":"https://api.github.com/repos/giftcardzen/deploy-script/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/giftcardzen/deploy-script/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/giftcardzen/deploy-script/git/refs{/sha}","trees_url":"https://api.github.com/repos/giftcardzen/deploy-script/git/trees{/sha}","statuses_url":"https://api.github.com/repos/giftcardzen/deploy-script/statuses/{sha}","languages_url":"https://api.github.com/repos/giftcardzen/deploy-script/languages","stargazers_url":"https://api.github.com/repos/giftcardzen/deploy-script/stargazers","contributors_url":"https://api.github.com/repos/giftcardzen/deploy-script/contributors","subscribers_url":"https://api.github.com/repos/giftcardzen/deploy-script/subscribers","subscription_url":"https://api.github.com/repos/giftcardzen/deploy-script/subscription","commits_url":"https://api.github.com/repos/giftcardzen/deploy-script/commits{/sha}","git_commits_url":"https://api.github.com/repos/giftcardzen/deploy-script/git/commits{/sha}","comments_url":"https://api.github.com/repos/giftcardzen/deploy-script/comments{/number}","issue_comment_url":"https://api.github.com/repos/giftcardzen/deploy-script/issues/comments{/number}","contents_url":"https://api.github.com/repos/giftcardzen/deploy-script/contents/{+path}","compare_url":"https://api.github.com/repos/giftcardzen/deploy-script/compare/{base}...{head}","merges_url":"https://api.github.com/repos/giftcardzen/deploy-script/merges","archive_url":"https://api.github.com/repos/giftcardzen/deploy-script/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/giftcardzen/deploy-script/downloads","issues_url":"https://api.github.com/repos/giftcardzen/deploy-script/issues{/number}","pulls_url":"https://api.github.com/repos/giftcardzen/deploy-script/pulls{/number}","milestones_url":"https://api.github.com/repos/giftcardzen/deploy-script/milestones{/number}","notifications_url":"https://api.github.com/repos/giftcardzen/deploy-script/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/giftcardzen/deploy-script/labels{/name}","releases_url":"https://api.github.com/repos/giftcardzen/deploy-script/releases{/id}","deployments_url":"https://api.github.com/repos/giftcardzen/deploy-script/deployments","created_at":"2015-04-02T17:06:18Z","updated_at":"2016-04-26T21:38:13Z","pushed_at":"2016-04-26T21:48:08Z","git_url":"git://github.com/giftcardzen/deploy-script.git","ssh_url":"git@github.com:giftcardzen/deploy-script.git","clone_url":"https://github.com/giftcardzen/deploy-script.git","svn_url":"https://github.com/giftcardzen/deploy-script","homepage":"","size":119,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":17,"forks":0,"open_issues":17,"watchers":0,"default_branch":"develop"}},"base":{"label":"giftcardzen:develop","ref":"develop","sha":"6977023697428df5be382a1e2168a647247fb132","user":{"login":"giftcardzen","id":7176061,"avatar_url":"https://avatars.githubusercontent.com/u/7176061?v=3","gravatar_id":"","url":"https://api.github.com/users/giftcardzen","html_url":"https://github.com/giftcardzen","followers_url":"https://api.github.com/users/giftcardzen/followers","following_url":"https://api.github.com/users/giftcardzen/following{/other_user}","gists_url":"https://api.github.com/users/giftcardzen/gists{/gist_id}","starred_url":"https://api.github.com/users/giftcardzen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giftcardzen/subscriptions","organizations_url":"https://api.github.com/users/giftcardzen/orgs","repos_url":"https://api.github.com/users/giftcardzen/repos","events_url":"https://api.github.com/users/giftcardzen/events{/privacy}","received_events_url":"https://api.github.com/users/giftcardzen/received_events","type":"Organization","site_admin":false},"repo":{"id":33321198,"name":"deploy-script","full_name":"giftcardzen/deploy-script","owner":{"login":"giftcardzen","id":7176061,"avatar_url":"https://avatars.githubusercontent.com/u/7176061?v=3","gravatar_id":"","url":"https://api.github.com/users/giftcardzen","html_url":"https://github.com/giftcardzen","followers_url":"https://api.github.com/users/giftcardzen/followers","following_url":"https://api.github.com/users/giftcardzen/following{/other_user}","gists_url":"https://api.github.com/users/giftcardzen/gists{/gist_id}","starred_url":"https://api.github.com/users/giftcardzen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giftcardzen/subscriptions","organizations_url":"https://api.github.com/users/giftcardzen/orgs","repos_url":"https://api.github.com/users/giftcardzen/repos","events_url":"https://api.github.com/users/giftcardzen/events{/privacy}","received_events_url":"https://api.github.com/users/giftcardzen/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/giftcardzen/deploy-script","description":"Script for deploying Rails application from Codeship to Heroku","fork":false,"url":"https://api.github.com/repos/giftcardzen/deploy-script","forks_url":"https://api.github.com/repos/giftcardzen/deploy-script/forks","keys_url":"https://api.github.com/repos/giftcardzen/deploy-script/keys{/key_id}","collaborators_url":"https://api.github.com/repos/giftcardzen/deploy-script/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/giftcardzen/deploy-script/teams","hooks_url":"https://api.github.com/repos/giftcardzen/deploy-script/hooks","issue_events_url":"https://api.github.com/repos/giftcardzen/deploy-script/issues/events{/number}","events_url":"https://api.github.com/repos/giftcardzen/deploy-script/events","assignees_url":"https://api.github.com/repos/giftcardzen/deploy-script/assignees{/user}","branches_url":"https://api.github.com/repos/giftcardzen/deploy-script/branches{/branch}","tags_url":"https://api.github.com/repos/giftcardzen/deploy-script/tags","blobs_url":"https://api.github.com/repos/giftcardzen/deploy-script/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/giftcardzen/deploy-script/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/giftcardzen/deploy-script/git/refs{/sha}","trees_url":"https://api.github.com/repos/giftcardzen/deploy-script/git/trees{/sha}","statuses_url":"https://api.github.com/repos/giftcardzen/deploy-script/statuses/{sha}","languages_url":"https://api.github.com/repos/giftcardzen/deploy-script/languages","stargazers_url":"https://api.github.com/repos/giftcardzen/deploy-script/stargazers","contributors_url":"https://api.github.com/repos/giftcardzen/deploy-script/contributors","subscribers_url":"https://api.github.com/repos/giftcardzen/deploy-script/subscribers","subscription_url":"https://api.github.com/repos/giftcardzen/deploy-script/subscription","commits_url":"https://api.github.com/repos/giftcardzen/deploy-script/commits{/sha}","git_commits_url":"https://api.github.com/repos/giftcardzen/deploy-script/git/commits{/sha}","comments_url":"https://api.github.com/repos/giftcardzen/deploy-script/comments{/number}","issue_comment_url":"https://api.github.com/repos/giftcardzen/deploy-script/issues/comments{/number}","contents_url":"https://api.github.com/repos/giftcardzen/deploy-script/contents/{+path}","compare_url":"https://api.github.com/repos/giftcardzen/deploy-script/compare/{base}...{head}","merges_url":"https://api.github.com/repos/giftcardzen/deploy-script/merges","archive_url":"https://api.github.com/repos/giftcardzen/deploy-script/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/giftcardzen/deploy-script/downloads","issues_url":"https://api.github.com/repos/giftcardzen/deploy-script/issues{/number}","pulls_url":"https://api.github.com/repos/giftcardzen/deploy-script/pulls{/number}","milestones_url":"https://api.github.com/repos/giftcardzen/deploy-script/milestones{/number}","notifications_url":"https://api.github.com/repos/giftcardzen/deploy-script/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/giftcardzen/deploy-script/labels{/name}","releases_url":"https://api.github.com/repos/giftcardzen/deploy-script/releases{/id}","deployments_url":"https://api.github.com/repos/giftcardzen/deploy-script/deployments","created_at":"2015-04-02T17:06:18Z","updated_at":"2016-04-26T21:38:13Z","pushed_at":"2016-04-26T21:48:08Z","git_url":"git://github.com/giftcardzen/deploy-script.git","ssh_url":"git@github.com:giftcardzen/deploy-script.git","clone_url":"https://github.com/giftcardzen/deploy-script.git","svn_url":"https://github.com/giftcardzen/deploy-script","homepage":"","size":119,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":17,"forks":0,"open_issues":17,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/giftcardzen/deploy-script/pulls/108"},"html":{"href":"https://github.com/giftcardzen/deploy-script/pull/108"},"issue":{"href":"https://api.github.com/repos/giftcardzen/deploy-script/issues/108"},"comments":{"href":"https://api.github.com/repos/giftcardzen/deploy-script/issues/108/comments"},"review_comments":{"href":"https://api.github.com/repos/giftcardzen/deploy-script/pulls/108/comments"},"review_comment":{"href":"https://api.github.com/repos/giftcardzen/deploy-script/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/giftcardzen/deploy-script/pulls/108/commits"},"statuses":{"href":"https://api.github.com/repos/giftcardzen/deploy-script/statuses/f0353c2bfb373e190cdd5f3576d77f9cd5e0e952"}}}}