@@ -81,135 +81,4 @@ begin
81
81
task :default => [ :speedy_tests ]
82
82
rescue LoadError
83
83
# allow for bundle install --without development:test
84
- end
85
-
86
- desc "deploy stringer on Heroku"
87
- task :deploy do
88
-
89
- require 'excon'
90
- require 'formatador'
91
- require 'json'
92
- require 'netrc'
93
- require 'rendezvous'
94
- require 'securerandom'
95
-
96
- Formatador . display_line ( "[negative]<> deploying stringer to Heroku[/]" )
97
-
98
- # grab netrc credentials, set by toolbelt via `heroku login`
99
- Formatador . display_line ( "[negative]<> reading your global Heroku credentials from ~/.netrc (set when you ran heroku login)...[/]" )
100
- _ , password = Netrc . read [ 'api.heroku.com' ]
101
-
102
- # setup excon for API calls
103
- heroku = Excon . new (
104
- 'https://api.heroku.com' ,
105
- :headers => {
106
- "Accept" => "application/vnd.heroku+json; version=3" ,
107
- "Authorization" => "Basic #{ [ ':' << password ] . pack ( 'm' ) . delete ( "\r \n " ) } " ,
108
- "Content-Type" => "application/json"
109
- }
110
- )
111
-
112
- #heroku create
113
- Formatador . display_line ( "[negative]<> creating app[/]" )
114
- app_data = JSON . parse ( heroku . post ( :path => "/apps" ) . body )
115
-
116
- #git push heroku master
117
- Formatador . display_line ( "[negative]<> pushing code to [underline]#{ app_data [ 'name' ] } [/]" )
118
- `git push git@heroku.com:#{ app_data [ 'name' ] } .git master`
119
-
120
- heroku . reset # reset socket as git push may take long enough for timeout
121
-
122
- #heroku config:set SECRET_TOKEN=`openssl rand -hex 20`
123
- Formatador . display_line ( "[negative]<> setting SECRET_TOKEN on [underline]#{ app_data [ 'name' ] } [/]" )
124
- heroku . patch (
125
- :body => { "SECRET_TOKEN" => SecureRandom . hex ( 20 ) } . to_json ,
126
- :path => "/apps/#{ app_data [ 'id' ] } /config-vars"
127
- )
128
-
129
- #heroku run rake db:migrate
130
- Formatador . display_line ( "[negative]<> running `rake db:migrate` on [underline]#{ app_data [ 'name' ] } [/]" )
131
- run_data = JSON . parse ( heroku . post (
132
- :body => {
133
- "attach" => true ,
134
- "command" => "rake db:migrate"
135
- } . to_json ,
136
- :path => "/apps/#{ app_data [ 'id' ] } /dynos"
137
- ) . body )
138
- Rendezvous . start (
139
- :url => run_data [ 'attach_url' ]
140
- )
141
-
142
- heroku . reset # reset socket as db:migrate may take long enough for timeout
143
-
144
- #heroku restart
145
- Formatador . display_line ( "[negative]<> restarting [underline]#{ app_data [ 'name' ] } [/]" )
146
- heroku . delete ( :path => "/apps/#{ app_data [ 'id' ] } /dynos" )
147
-
148
- #heroku addons:add scheduler
149
- Formatador . display_line ( "[negative]<> adding scheduler:standard to [underline]#{ app_data [ 'name' ] } [/]" )
150
- heroku . post (
151
- :body => { "plan" => { "name" => "scheduler:standard" } } . to_json ,
152
- :path => "/apps/#{ app_data [ 'id' ] } /addons"
153
- )
154
-
155
- #heroku addons:open scheduler
156
- Formatador . display_lines ( [
157
- "[negative]<> Add `[bold]rake lazy_fetch[/][negative]` hourly task at [underline]https://api.heroku.com/apps/#{ app_data [ 'id' ] } /addons/scheduler:standard[/]" ,
158
- "[negative]<> Impatient? After adding feeds, immediately fetch the latest with `heroku run rake fetch_feeds -a #{ app_data [ 'name' ] } `" ,
159
- "[negative]<> stringer available at [underline]#{ app_data [ 'web_url' ] } [/]"
160
- ] )
161
- end
162
-
163
- desc "update stringer on heroku"
164
- task :update , :app do |task , args |
165
-
166
- require 'excon'
167
- require 'formatador'
168
- require 'json'
169
- require 'netrc'
170
- require 'rendezvous'
171
-
172
- unless args . app
173
- Formatador . display_line ( "[negative]! Error: App required, please run as `bundle exec rake update[app]`[/]" )
174
- exit
175
- end
176
-
177
- Formatador . display_line ( "[negative]<> updating Heroku stringer on [underline]#{ args . app } [/]" )
178
-
179
- # grab netrc credentials, set by toolbelt via `heroku login`
180
- Formatador . display_line ( "[negative]<> reading your global Heroku credentials from ~/.netrc (set when you ran heroku login)...[/]" )
181
- _ , password = Netrc . read [ 'api.heroku.com' ]
182
-
183
- # setup excon for API calls
184
- heroku = Excon . new (
185
- 'https://api.heroku.com' ,
186
- :headers => {
187
- "Accept" => "application/vnd.heroku+json; version=3" ,
188
- "Authorization" => "Basic #{ [ ':' << password ] . pack ( 'm' ) . delete ( "\r \n " ) } " ,
189
- "Content-Type" => "application/json"
190
- }
191
- )
192
-
193
- #git push heroku master
194
- Formatador . display_line ( "[negative]<> pushing code to [underline]#{ args . app } [/]" )
195
- `git push git@heroku.com:#{ args . app } .git master`
196
-
197
- #heroku run rake db:migrate
198
- Formatador . display_line ( "[negative]<> running `rake db:migrate` on [underline]#{ args . app } [/]" )
199
- run_data = JSON . parse ( heroku . post (
200
- :body => {
201
- "attach" => true ,
202
- "command" => "rake db:migrate"
203
- } . to_json ,
204
- :path => "/apps/#{ args . app } /dynos"
205
- ) . body )
206
- Rendezvous . start (
207
- :url => run_data [ 'attach_url' ]
208
- )
209
-
210
- heroku . reset # reset socket as db:migrate may take long enough for timeout
211
-
212
- #heroku restart
213
- Formatador . display_line ( "[negative]<> restarting [underline]#{ args . app } [/]" )
214
- heroku . delete ( :path => "/apps/#{ args . app } /dynos" )
215
- end
84
+ end
0 commit comments