lita-github-web-hooks-core 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +26 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +56 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/lita/extensions/github_web_hooks_core/hook_receiver.rb +72 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/commit_comment.rb +41 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/create.rb +27 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/delete.rb +27 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/deployment.rb +44 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/deployment_status.rb +54 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/download.rb +8 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/follow.rb +8 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/fork.rb +25 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/fork_apply.rb +8 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/gist.rb +8 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/gollum.rb +27 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/hook.rb +13 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/issue_comment.rb +49 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/issues.rb +35 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/member.rb +23 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/membership.rb +28 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/page_build.rb +19 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/ping.rb +17 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/public.rb +14 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb +87 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/pull_request_review_comment.rb +69 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/push.rb +43 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/release.rb +27 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/repo_hooks.rb +24 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/repository.rb +19 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/status.rb +34 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/team_add.rb +23 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks/watch.rb +22 -0
- data/lib/lita/extensions/github_web_hooks_core/hooks.rb +28 -0
- data/lib/lita/extensions/github_web_hooks_core/listeners.rb +22 -0
- data/lib/lita/extensions/github_web_hooks_core.rb +17 -0
- data/lib/lita/github/web/hooks/core/version.rb +9 -0
- data/lib/lita/github/web/hooks/core.rb +11 -0
- data/lib/lita-github-web-hooks-core.rb +8 -0
- data/lita-github-web-hooks-core.gemspec +31 -0
- data/locales/en.yml +4 -0
- data/templates/.gitkeep +0 -0
- data/templates/commit_comment.erb +3 -0
- data/templates/create.erb +1 -0
- data/templates/delete.erb +1 -0
- data/templates/deployment.erb +1 -0
- data/templates/deployment_status.erb +1 -0
- data/templates/fork.erb +1 -0
- data/templates/gollum.erb +2 -0
- data/templates/issue_comment.erb +3 -0
- data/templates/issues.erb +2 -0
- data/templates/member.erb +1 -0
- data/templates/membership.erb +1 -0
- data/templates/page_build.erb +1 -0
- data/templates/public.erb +1 -0
- data/templates/pull_request.erb +1 -0
- data/templates/pull_request_review_comment.erb +3 -0
- data/templates/push.erb +1 -0
- data/templates/release.erb +2 -0
- data/templates/repository.erb +1 -0
- data/templates/status.erb +5 -0
- data/templates/team_add.erb +1 -0
- data/templates/watch.erb +1 -0
- metadata +271 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ff338404765098ef6895b51a6b1d804b4d64cfda
|
4
|
+
data.tar.gz: e4e49138c7319db3953aa999e01d4e05473f64c4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fa7f89f45e0372abbee699ad4d30f11ae0af3fac7c48046e85e4307bb066877349ac269996dd7cb86ed022471a925ecf41a69b357a9ba7ec75ab96dd064a130a
|
7
|
+
data.tar.gz: 178966aad808956ce0640f67330e55236332b698f03cc65951696e58572f860fbe284cf192d4ec332a87dd44ad62600b8e6af8d24228694b8849d8385d15d756
|
data/.gitignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
/.bundle/
|
19
|
+
/.yardoc
|
20
|
+
/Gemfile.lock
|
21
|
+
/_yardoc/
|
22
|
+
/coverage/
|
23
|
+
/doc/
|
24
|
+
/pkg/
|
25
|
+
/spec/reports/
|
26
|
+
/tmp/
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014, 2015 Jimmy Cuadra, Jim Van Fleet
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 QuietStream Financial, Jim Van Fleet
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Lita::Github::WebHooks::Core
|
2
|
+
|
3
|
+
Lita and GitHub web hooks are two great tastes that taste great together.
|
4
|
+
|
5
|
+
This extension is designed to make using GitHub web hooks as easy as possible in your own handlers. You may be familiar with the [three types of events](http://docs.lita.io/plugin-authoring/handlers/) Lita supports. In short, this extension transforms raw data arriving via the [HTTP routing](http://docs.lita.io/plugin-authoring/handlers/#http-routes) system, and publishes a Ruby object (including the original payload) for consumption via an [event route](http://docs.lita.io/plugin-authoring/handlers/#event-routes). This way, with a simple ```on``` declaration in your handler, you've got the power of the GitHub and Lita at your fingertips.
|
6
|
+
|
7
|
+
Installing this extension in your lita bot will not change its behavior. Extensions are designed to enable handlers, and this one is no exception. A [simple example handler](https://github.com/GetLevvel/lita-github-web-hooks-storer) demonstrates how easy it can be to get up and running with GitHub Web Hooks in your own bot.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add lita-github-web-hooks-core to your Lita plugin's gemspec:
|
12
|
+
|
13
|
+
``` ruby
|
14
|
+
spec.add_runtime_dependency "lita-github-web-hooks-core"
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
## Hooks and Listeners
|
22
|
+
|
23
|
+
A Hook is intended to capture a [Webhook event from GitHub](https://developer.github.com/webhooks/). There is only one kind of Hook per GitHub API event type. This extension takes events from the HTTP Post mechanism of interacting with Lita and publishes them on the event mechanism inside lita. It also provides a collection of data-transfer objects designed to facilitate working with the payloads that GitHub sends along with the webhooks in question within your own plugins.
|
24
|
+
|
25
|
+
For example, receipt of a deployment message might query a statistics API to publish performance metrics about the deployment that's being retired. Tagging a pull request event might trigger a GitHub status update, or a prompt within your chat room for someone to review it. Want to use [atmos/heaven](https://github.com/atmos/heaven), but have a coffeescript allergy? This is a great starting place. Let your imagination be your guide!
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
1. Subclass the HookReceiver Handler class to create something you can mount at a path with http.post and register with Lita
|
30
|
+
1. Define a listener, specifying which events you'd want to subscribe to.
|
31
|
+
1. Register that listener as a Lita handler.
|
32
|
+
|
33
|
+
A [step-by-step walkthrough](https://github.com/GetLevvel/lita-github-web-hooks-storer/blob/master/docs/handler-walkthrough.md)
|
34
|
+
is available at [our example handler](https://github.com/GetLevvel/lita-github-web-hooks-storer/).
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
## Configuration
|
39
|
+
|
40
|
+
In the chatbot itself, where your own users will be interacting with the bot, the listeners will need to be configured. Listeners can listen only to particular events, or all events.
|
41
|
+
|
42
|
+
## Development
|
43
|
+
|
44
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
45
|
+
|
46
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/GetLevvel/lita-github-web-hooks-core. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
51
|
+
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
56
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "lita/github/web/hooks/core"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
module Lita
|
2
|
+
module Extensions
|
3
|
+
module GitHubWebHooksCore
|
4
|
+
class HookReceiver < Handler
|
5
|
+
|
6
|
+
def logger
|
7
|
+
Lita.logger
|
8
|
+
end
|
9
|
+
|
10
|
+
def receive_hook(request, response)
|
11
|
+
event_type = event_type_from_request(request)
|
12
|
+
logger.debug("Received #{event_type} webhook")
|
13
|
+
if valid?(request)
|
14
|
+
payload = extract_payload(request)
|
15
|
+
robot.trigger(event_type, payload.merge(event_type: event_type))
|
16
|
+
end
|
17
|
+
|
18
|
+
response.status = 202
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def event_type_from_request(request)
|
24
|
+
request.env["HTTP_X_GITHUB_EVENT"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def extract_payload(request)
|
28
|
+
case (media_type = request.media_type)
|
29
|
+
when "application/x-www-form-urlencoded"
|
30
|
+
MultiJson.load(request["payload"])
|
31
|
+
when "application/json"
|
32
|
+
MultiJson.load(request.body)
|
33
|
+
else
|
34
|
+
raise "GitHub web hooks: Invalid HTTP Content-Type header: #{media_type}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def github_cidrs
|
39
|
+
response = http.get("https://api.github.com/meta")
|
40
|
+
data = MultiJson.load(response.body)
|
41
|
+
data["hooks"]
|
42
|
+
end
|
43
|
+
|
44
|
+
def valid?(request)
|
45
|
+
valid_content_type?(request) && valid_ip?(request)
|
46
|
+
end
|
47
|
+
|
48
|
+
def valid_content_type?(request)
|
49
|
+
validity = request.media_type == "application/json"
|
50
|
+
Lita.logger.warn(
|
51
|
+
"GitHub web hook received with invalid media type: #{request.media_type}"
|
52
|
+
) unless validity
|
53
|
+
validity
|
54
|
+
end
|
55
|
+
|
56
|
+
def valid_ip?(request)
|
57
|
+
ip = request.ip
|
58
|
+
cidrs = github_cidrs || [ "192.30.252.0/22" ]
|
59
|
+
|
60
|
+
# FIXME: github_cidrs has been null in prod?
|
61
|
+
# FIXME: this behaves poorly behind a NAT firewall, allow a whitelist
|
62
|
+
validity = cidrs.any? do |cidr|
|
63
|
+
::NetAddr::CIDR.create(cidr).contains?(ip)
|
64
|
+
end
|
65
|
+
|
66
|
+
Lita.logger.warn("GitHub web hook received from invalid IP: #{ip}") unless validity
|
67
|
+
validity
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Lita::Extensions
|
2
|
+
module GitHubWebHooksCore
|
3
|
+
module Hooks
|
4
|
+
class CommitComment < Hook
|
5
|
+
include Lita::Extensions::GitHubWebHooksCore::Hooks::RepoHooks
|
6
|
+
def commenter
|
7
|
+
payload["sender"]
|
8
|
+
end
|
9
|
+
|
10
|
+
def url
|
11
|
+
comment["html_url"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def body
|
15
|
+
comment["body"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def comment
|
19
|
+
payload["comment"]
|
20
|
+
end
|
21
|
+
|
22
|
+
def commit_id
|
23
|
+
comment["commit_id"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def attributes
|
27
|
+
{
|
28
|
+
commenter: commenter,
|
29
|
+
commit_id: commit_id,
|
30
|
+
url: url,
|
31
|
+
body: body,
|
32
|
+
comment: comment,
|
33
|
+
repository: repository,
|
34
|
+
repo: repo
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Lita::Extensions
|
2
|
+
module GitHubWebHooksCore
|
3
|
+
module Hooks
|
4
|
+
class Create < Hook
|
5
|
+
include Lita::Extensions::GitHubWebHooksCore::Hooks::RepoHooks
|
6
|
+
def creator
|
7
|
+
payload["sender"]["login"]
|
8
|
+
end
|
9
|
+
def creation
|
10
|
+
payload["ref_type"]
|
11
|
+
end
|
12
|
+
def creation_name
|
13
|
+
payload["ref"]
|
14
|
+
end
|
15
|
+
def attributes
|
16
|
+
{
|
17
|
+
creator: creator,
|
18
|
+
creation: creation,
|
19
|
+
creation_name: creation_name,
|
20
|
+
repository: repository,
|
21
|
+
repo: repo
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Lita::Extensions
|
2
|
+
module GitHubWebHooksCore
|
3
|
+
module Hooks
|
4
|
+
class Delete < Hook
|
5
|
+
include Lita::Extensions::GitHubWebHooksCore::Hooks::RepoHooks
|
6
|
+
def deletor
|
7
|
+
payload["sender"]["login"]
|
8
|
+
end
|
9
|
+
def deletion
|
10
|
+
payload["ref_type"]
|
11
|
+
end
|
12
|
+
def deletion_name
|
13
|
+
payload["ref"]
|
14
|
+
end
|
15
|
+
def attributes
|
16
|
+
{
|
17
|
+
deletor: deletor,
|
18
|
+
deletion: deletion,
|
19
|
+
deletion_name: deletion_name,
|
20
|
+
repository: repository,
|
21
|
+
repo: repo
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Lita::Extensions
|
2
|
+
module GitHubWebHooksCore
|
3
|
+
module Hooks
|
4
|
+
class Deployment < Hook
|
5
|
+
include Lita::Extensions::GitHubWebHooksCore::Hooks::RepoHooks
|
6
|
+
def sha
|
7
|
+
deploy["sha"]
|
8
|
+
end
|
9
|
+
|
10
|
+
def environment
|
11
|
+
deploy["environment"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def start_time
|
15
|
+
deploy["created_at"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def deploy
|
19
|
+
payload["deployment"]
|
20
|
+
end
|
21
|
+
|
22
|
+
def deployer
|
23
|
+
payload["sender"]["login"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def ref
|
27
|
+
deploy["ref"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def attributes
|
31
|
+
{
|
32
|
+
sha: sha,
|
33
|
+
ref: ref,
|
34
|
+
repo: repo,
|
35
|
+
environment: environment,
|
36
|
+
start_time: start_time,
|
37
|
+
deploy: deploy,
|
38
|
+
deployer: deployer
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Lita::Extensions
|
2
|
+
module GitHubWebHooksCore
|
3
|
+
module Hooks
|
4
|
+
class DeploymentStatus < Hook
|
5
|
+
include Lita::Extensions::GitHubWebHooksCore::Hooks::RepoHooks
|
6
|
+
def status
|
7
|
+
payload["deployment_status"]["state"]
|
8
|
+
end
|
9
|
+
|
10
|
+
def deployment_description
|
11
|
+
[deploy["description"], status].join(": ")
|
12
|
+
end
|
13
|
+
|
14
|
+
def sha
|
15
|
+
deploy["sha"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def environment
|
19
|
+
deploy["environment"]
|
20
|
+
end
|
21
|
+
|
22
|
+
def start_time
|
23
|
+
deploy["created_at"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def deploy
|
27
|
+
payload["deployment"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def deployer
|
31
|
+
payload["sender"]["login"]
|
32
|
+
end
|
33
|
+
|
34
|
+
def ref
|
35
|
+
deploy["ref"]
|
36
|
+
end
|
37
|
+
|
38
|
+
def attributes
|
39
|
+
{
|
40
|
+
status: status,
|
41
|
+
deployment_description: deployment_description,
|
42
|
+
ref: ref,
|
43
|
+
repo: repo,
|
44
|
+
sha: sha,
|
45
|
+
environment: environment,
|
46
|
+
start_time: start_time,
|
47
|
+
deploy: deploy,
|
48
|
+
deployer: deployer
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Lita::Extensions
|
2
|
+
module GitHubWebHooksCore
|
3
|
+
module Hooks
|
4
|
+
class Fork < Hook
|
5
|
+
include Lita::Extensions::GitHubWebHooksCore::Hooks::RepoHooks
|
6
|
+
def forker
|
7
|
+
payload["sender"]["login"]
|
8
|
+
end
|
9
|
+
def source
|
10
|
+
payload["forkee"]["full_name"]
|
11
|
+
end
|
12
|
+
def target
|
13
|
+
repo
|
14
|
+
end
|
15
|
+
def attributes
|
16
|
+
{
|
17
|
+
forker: forker,
|
18
|
+
source: source,
|
19
|
+
target: target
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Lita::Extensions
|
2
|
+
module GitHubWebHooksCore
|
3
|
+
module Hooks
|
4
|
+
class Gollum < Hook
|
5
|
+
include Lita::Extensions::GitHubWebHooksCore::Hooks::RepoHooks
|
6
|
+
def author
|
7
|
+
payload["sender"]["login"]
|
8
|
+
end
|
9
|
+
def title
|
10
|
+
payload["pages"].first["page_name"]
|
11
|
+
end
|
12
|
+
def url
|
13
|
+
payload["pages"].first["html_url"]
|
14
|
+
end
|
15
|
+
def attributes
|
16
|
+
{
|
17
|
+
author: author,
|
18
|
+
title: title,
|
19
|
+
url: url,
|
20
|
+
repository: repository,
|
21
|
+
repo: repo
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Lita::Extensions
|
2
|
+
module GitHubWebHooksCore
|
3
|
+
module Hooks
|
4
|
+
class IssueComment < Hook
|
5
|
+
include Lita::Extensions::GitHubWebHooksCore::Hooks::RepoHooks
|
6
|
+
def body
|
7
|
+
comment["body"]
|
8
|
+
end
|
9
|
+
|
10
|
+
def comment
|
11
|
+
payload["comment"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def commenter
|
15
|
+
payload["sender"]["login"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def url
|
19
|
+
comment["html_url"]
|
20
|
+
end
|
21
|
+
|
22
|
+
def issue
|
23
|
+
payload["issue"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def number
|
27
|
+
issue["number"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def target
|
31
|
+
issue["title"]
|
32
|
+
end
|
33
|
+
|
34
|
+
def attributes
|
35
|
+
{
|
36
|
+
body: body,
|
37
|
+
comment: comment,
|
38
|
+
commenter: commenter,
|
39
|
+
number: number,
|
40
|
+
repo: repo,
|
41
|
+
url: url,
|
42
|
+
issue: issue,
|
43
|
+
target: target
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Lita::Extensions
|
2
|
+
module GitHubWebHooksCore
|
3
|
+
module Hooks
|
4
|
+
class Issues < Hook
|
5
|
+
include Lita::Extensions::GitHubWebHooksCore::Hooks::RepoHooks
|
6
|
+
def creator
|
7
|
+
payload["sender"]["login"]
|
8
|
+
end
|
9
|
+
def action
|
10
|
+
payload["action"]
|
11
|
+
end
|
12
|
+
def number
|
13
|
+
payload["issue"]["number"]
|
14
|
+
end
|
15
|
+
def title
|
16
|
+
payload["issue"]["title"]
|
17
|
+
end
|
18
|
+
def url
|
19
|
+
payload["issue"]["html_url"]
|
20
|
+
end
|
21
|
+
def attributes
|
22
|
+
{
|
23
|
+
creator: creator,
|
24
|
+
action: action,
|
25
|
+
number: number,
|
26
|
+
title: title,
|
27
|
+
url: url,
|
28
|
+
repository: repository,
|
29
|
+
repo: repo
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|