lita-heroku 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -0
- data/lib/lita/handlers/heroku.rb +19 -9
- data/lita-heroku.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ea1479c89addbafb3f848555eecd0ccae6f164d
|
4
|
+
data.tar.gz: b5211f61d5bbae6b64a9b3a38560726b6f9154ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a145aac191080e00fc5fbd605c8999fd70143564140bb45305971fde186b2c71625a79153189eb187847d0fcf5c1cdab34686996d168a4809381ea477778914
|
7
|
+
data.tar.gz: 73a357c27064d3cf5e72fc9fc1e18f3a5639858ef0e592af4f907552418d8e8d6a733d7ac182497dd98ca8283f2474417391ac936e3d40e8cb341bee8ff39cce
|
data/README.md
CHANGED
@@ -10,6 +10,20 @@ Add lita-heroku to your Lita instance's Gemfile:
|
|
10
10
|
gem "lita-heroku"
|
11
11
|
```
|
12
12
|
|
13
|
+
Create an oauth token and set it in config:
|
14
|
+
|
15
|
+
``` bash
|
16
|
+
heroku plugins:install https://github.com/heroku/heroku-oauth
|
17
|
+
heroku authorizations:create -d "Lita Bot"
|
18
|
+
echo "HEROKU_OAUTH_TOKEN=YOUR_TOKEN" >> .env
|
19
|
+
```
|
20
|
+
|
21
|
+
In your lita config:
|
22
|
+
|
23
|
+
``` ruby
|
24
|
+
config.handlers.heroku.oauth_token = ENV.fetch("HEROKU_OAUTH_TOKEN")
|
25
|
+
```
|
26
|
+
|
13
27
|
## Configuration
|
14
28
|
|
15
29
|
TODO: Describe any configuration attributes the plugin exposes.
|
data/lib/lita/handlers/heroku.rb
CHANGED
@@ -2,8 +2,8 @@ require "json"
|
|
2
2
|
module Lita
|
3
3
|
module Handlers
|
4
4
|
class Heroku < Handler
|
5
|
-
config :
|
6
|
-
config :
|
5
|
+
config :oauth_token, required: true
|
6
|
+
config :app_prefix
|
7
7
|
|
8
8
|
route(/^hk\s+([^ ]+)\s+(.+)/, :heroku_cmd, command: true, help: {
|
9
9
|
"hk [app name] [command]" => "example: 'lita hk production ps'"
|
@@ -15,7 +15,7 @@ module Lita
|
|
15
15
|
if command == "deploy"
|
16
16
|
heroku_deploy response
|
17
17
|
else
|
18
|
-
response.reply `#{heroku_bin} #{command} -a
|
18
|
+
response.reply `#{heroku_bin} #{command} -a #{config.app_prefix}#{environment}`
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -32,25 +32,35 @@ module Lita
|
|
32
32
|
end
|
33
33
|
|
34
34
|
route(/^hk deploy\s+(.+)/, :heroku_deploy, command: true, help: {
|
35
|
-
"hk
|
35
|
+
"hk [environment] deploy" => "example: 'lita hk production deploy'"
|
36
36
|
})
|
37
37
|
|
38
38
|
def heroku_deploy(response)
|
39
|
-
|
40
|
-
|
41
|
-
branch = "master"
|
39
|
+
bearer = config.oauth_token
|
40
|
+
app_name = "#{config.app_prefix}#{response.matches[0][0]}"
|
41
|
+
branch = response.matches[0][1] || "master"
|
42
|
+
|
43
|
+
apps = JSON.parse `curl -s "https://api.heroku.com/apps" -H "Authorization: Bearer #{bearer}" -H 'Accept: application/vnd.heroku+json; version=3'`
|
44
|
+
app = apps.select{|app| app["name"] == app_name }.first
|
45
|
+
app_id = app["id"]
|
42
46
|
|
43
47
|
build_response = `curl -s "https://kolkrabbi.herokuapp.com/apps/#{app_id}/github/push" -H "Authorization: Bearer #{bearer}" -d '{"branch":"#{branch}"}'`
|
44
48
|
build_response = JSON.parse build_response
|
45
49
|
|
46
50
|
if build_response.key?("build") && build_response["build"]["status"] == "pending"
|
47
|
-
response.reply("
|
51
|
+
response.reply("Deploying #{branch} to #{app_name}.")
|
48
52
|
else
|
49
53
|
$stdout.puts build_response
|
50
|
-
response.reply("Deploy could not be started.
|
54
|
+
response.reply("Deploy could not be started. Response: #{build_response}")
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
58
|
+
def api(bearer, uri, data=nil)
|
59
|
+
cmd = %Q{curl -s "https://kolkrabbi.herokuapp.com#{uri}" -H "Authorization: Bearer #{bearer}" -H 'range: name ..; order=asc, max=1000'}
|
60
|
+
cmd += %Q{-d '#{data}'} if data
|
61
|
+
JSON.parse `#{cmd}`
|
62
|
+
end
|
63
|
+
|
54
64
|
Lita.register_handler(self)
|
55
65
|
end
|
56
66
|
end
|
data/lita-heroku.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-heroku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Boehs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|