Class: Paratrooper::Deploy
- Inherits:
-
Object
- Object
- Paratrooper::Deploy
- Extended by:
- Forwardable
- Defined in:
- lib/paratrooper/deploy.rb
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#activate_maintenance_mode ⇒ Object
Public: Activates Heroku maintenance mode.
-
#add_remote_task(task_name) ⇒ Object
Public: Runs task on your heroku instance.
-
#app_restart ⇒ Object
Public: Restarts application on Heroku.
-
#deactivate_maintenance_mode ⇒ Object
Public: Deactivates Heroku maintenance mode.
-
#default_deploy ⇒ Object
(also: #deploy)
Public: Execute common deploy steps.
-
#initialize(app_name, options = {}, &block) ⇒ Deploy
constructor
Public: Initializes a Deploy.
-
#push_repo ⇒ Object
Public: Pushes repository to Heroku.
-
#run_migrations ⇒ Object
Public: Runs rails database migrations on your application.
-
#setup ⇒ Object
Public: Hook method called first in the deploy process.
-
#teardown ⇒ Object
Public: Hook method called last in the deploy process.
- #update_repo_tag ⇒ Object
Constructor Details
#initialize(app_name, options = {}, &block) ⇒ Deploy
Public: Initializes a Deploy
app_name - A String naming the Heroku application to be interacted with. options - The Hash options is used to provide additional functionality.
:screen_notifier - Object used for outputting to screen
(optional).
:notifiers - Array of objects interested in being
notified of steps in deployment process
(optional).
:heroku - Object wrapper around heroku-api (optional).
:branch - String name to be used as a git reference
point for deploying from specific branch.
Use :head to deploy from current branch
(optional).
:force - Force deploy using (-f flag) on deploy
(optional, default: false)
:system_caller - Object responsible for calling system
commands (optional).
:protocol - String web protocol to be used when pinging
application (optional, default: 'http').
:deployment_host - String host name to be used in git URL
(optional, default: 'heroku.com').
:migration_check - Object responsible for checking pending
migrations (optional).
:maintenance - If true, show maintenance page when pending
migrations exists. False by default (optional).
migrations (optional).
:api_key - String version of heroku api key.
(default: looks in local Netrc file).
:http_client - Object responsible for making http calls
(optional).
51 52 53 54 |
# File 'lib/paratrooper/deploy.rb', line 51 def initialize(app_name, = {}, &block) config.attributes = .merge(app_name: app_name) block.call(config) if block_given? end |
Instance Attribute Details
#config ⇒ Object
56 57 58 |
# File 'lib/paratrooper/deploy.rb', line 56 def config @config ||= Configuration.new end |
Class Method Details
.call(app_name, options = {}, &block) ⇒ Object
15 16 17 |
# File 'lib/paratrooper/deploy.rb', line 15 def self.call(app_name, = {}, &block) new(app_name, , &block).deploy end |
Instance Method Details
#activate_maintenance_mode ⇒ Object
Public: Activates Heroku maintenance mode.
89 90 91 92 93 94 95 |
# File 'lib/paratrooper/deploy.rb', line 89 def activate_maintenance_mode return unless maintenance_necessary? callback(:activate_maintenance_mode) do notify(:activate_maintenance_mode) heroku.app_maintenance_on end end |
#add_remote_task(task_name) ⇒ Object
Public: Runs task on your heroku instance.
task_name - String name of task to run on heroku instance
167 168 169 |
# File 'lib/paratrooper/deploy.rb', line 167 def add_remote_task(task_name) heroku.run_task(task_name) end |
#app_restart ⇒ Object
Public: Restarts application on Heroku.
131 132 133 134 135 136 137 |
# File 'lib/paratrooper/deploy.rb', line 131 def app_restart return unless restart_required? callback(:app_restart) do notify(:app_restart) heroku.app_restart end end |
#deactivate_maintenance_mode ⇒ Object
Public: Deactivates Heroku maintenance mode.
99 100 101 102 103 104 105 |
# File 'lib/paratrooper/deploy.rb', line 99 def deactivate_maintenance_mode return unless maintenance_necessary? callback(:deactivate_maintenance_mode) do notify(:deactivate_maintenance_mode) heroku.app_maintenance_off end end |
#default_deploy ⇒ Object Also known as: deploy
Public: Execute common deploy steps.
Default deploy consists of:
-
Activating maintenance page
-
Pushing repository to Heroku
-
Running database migrations
-
Restarting application on Heroku
-
Deactivating maintenance page
Alias: #deploy
149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/paratrooper/deploy.rb', line 149 def default_deploy setup update_repo_tag push_repo maintenance_mode do run_migrations app_restart end teardown rescue Paratrooper::Error => e abort(e.) end |
#push_repo ⇒ Object
Public: Pushes repository to Heroku.
Based on the following precedence: branch_name / ‘master’
112 113 114 115 116 117 |
# File 'lib/paratrooper/deploy.rb', line 112 def push_repo callback(:push_repo) do notify(:push_repo) source_control.push_to_deploy end end |
#run_migrations ⇒ Object
Public: Runs rails database migrations on your application.
121 122 123 124 125 126 127 |
# File 'lib/paratrooper/deploy.rb', line 121 def run_migrations return unless pending_migrations? callback(:run_migrations) do notify(:run_migrations) heroku.run_migrations end end |
#setup ⇒ Object
Public: Hook method called first in the deploy process.
62 63 64 65 66 67 |
# File 'lib/paratrooper/deploy.rb', line 62 def setup callback(:setup) do notify(:setup) migration_check.last_deployed_commit end end |
#teardown ⇒ Object
Public: Hook method called last in the deploy process.
71 72 73 74 75 76 |
# File 'lib/paratrooper/deploy.rb', line 71 def teardown callback(:teardown) do notify(:teardown) end notify(:deploy_finished) end |
#update_repo_tag ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/paratrooper/deploy.rb', line 78 def update_repo_tag if source_control.taggable? callback(:update_repo_tag) do notify(:update_repo_tag) source_control.update_repo_tag end end end |