gh-events 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +60 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +38 -0
- data/README.md +59 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/gh-event2text +8 -0
- data/exe/gh-events +15 -0
- data/gh-events.gemspec +42 -0
- data/lib/gh-events.rb +1 -0
- data/lib/gh/events.rb +46 -0
- data/lib/gh/events/text.rb +73 -0
- data/lib/gh/events/version.rb +5 -0
- data/lib/hash.rb +9 -0
- data/res/events.yml +194 -0
- data/res/plain.yml +118 -0
- data/res/slack.yml +215 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e1cff1386c5673a98772cf99e50149162e0f010f65c8e59a6bb40779fbc10233
|
4
|
+
data.tar.gz: fede3370b5bd12f80c75a6cc4b239e324df11bbc0d970419ef4a44eab3f4a7bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 70e2bd1df73c6641d6645d40804e7526de092512fd068d02924f7d8a5966d1cb2a120a6d3e38894f77ee4cb390992dfc63b3db81c6f10c401cc620fed61b9944
|
7
|
+
data.tar.gz: 8dd77aaaed11e14dccb267a86f9ce211998cd91bb45de3c8db8f53dec76d8fbc837e45d9a4a0551489ac79a14f6e50f9f9f64ebc7e9984c789b037ceed9fd489
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
#
|
3
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
|
+
#
|
5
|
+
version: 2
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
docker:
|
9
|
+
# specify the version you desire here
|
10
|
+
- image: circleci/ruby:2.6.5
|
11
|
+
|
12
|
+
# Specify service dependencies here if necessary
|
13
|
+
# CircleCI maintains a library of pre-built images
|
14
|
+
# documented at https://circleci.com/docs/2.0/circleci-images/
|
15
|
+
# - image: circleci/postgres:9.4
|
16
|
+
|
17
|
+
working_directory: ~/repo
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- checkout
|
21
|
+
|
22
|
+
# Download and cache dependencies
|
23
|
+
- restore_cache:
|
24
|
+
keys:
|
25
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
26
|
+
# fallback to using the latest cache if no exact match is found
|
27
|
+
- v1-dependencies-
|
28
|
+
|
29
|
+
- run:
|
30
|
+
name: install dependencies
|
31
|
+
command: |
|
32
|
+
gem install bundler:2.0.2
|
33
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
34
|
+
|
35
|
+
- save_cache:
|
36
|
+
paths:
|
37
|
+
- ./vendor/bundle
|
38
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
39
|
+
|
40
|
+
# run tests!
|
41
|
+
- run:
|
42
|
+
name: run tests
|
43
|
+
command: |
|
44
|
+
mkdir /tmp/test-results
|
45
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \
|
46
|
+
circleci tests split --split-by=timings)"
|
47
|
+
|
48
|
+
bundle exec rspec \
|
49
|
+
--format progress \
|
50
|
+
--format RspecJunitFormatter \
|
51
|
+
--out /tmp/test-results/rspec.xml \
|
52
|
+
--format progress \
|
53
|
+
$TEST_FILES
|
54
|
+
|
55
|
+
# collect reports
|
56
|
+
- store_test_results:
|
57
|
+
path: /tmp/test-results
|
58
|
+
- store_artifacts:
|
59
|
+
path: /tmp/test-results
|
60
|
+
destination: test-results
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.5
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gh-events (0.8.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
rspec (3.9.0)
|
12
|
+
rspec-core (~> 3.9.0)
|
13
|
+
rspec-expectations (~> 3.9.0)
|
14
|
+
rspec-mocks (~> 3.9.0)
|
15
|
+
rspec-core (3.9.0)
|
16
|
+
rspec-support (~> 3.9.0)
|
17
|
+
rspec-expectations (3.9.0)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.9.0)
|
20
|
+
rspec-mocks (3.9.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.9.0)
|
23
|
+
rspec-support (3.9.0)
|
24
|
+
rspec_junit_formatter (0.4.1)
|
25
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
bundler (~> 2.0)
|
32
|
+
gh-events!
|
33
|
+
rake (~> 10.0)
|
34
|
+
rspec (~> 3.0)
|
35
|
+
rspec_junit_formatter (~> 0.4)
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
2.0.2
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Github Events
|
2
|
+
|
3
|
+
Via Webhooks Github can send a plethora of events, which can be used to facilitate all kinds of automation.
|
4
|
+
|
5
|
+
These events are _untyped_, meaning they clearly lack a property `type` to identify the type of event received. (The rationale here might be that one would have differen webhook endpoints for each type of events. But maintaining lots of endpoints is cumbersome. When all the events end up in one endpoint, this library helps by adding a property `type` to the event.)
|
6
|
+
|
7
|
+
Additionally this library provides means of translating the plain event into a human readable textutal representation. This functionality is wrapped in a command line utility, for your convenience.
|
8
|
+
|
9
|
+
## Example Usage
|
10
|
+
|
11
|
+
You can use the command `gh-events` to list the types of events stortef in JSON files.
|
12
|
+
|
13
|
+
```
|
14
|
+
% gh-events spec/fixtures/*.json
|
15
|
+
events/001.json: commit_comment
|
16
|
+
events/002.json: create
|
17
|
+
events/003.json: delete
|
18
|
+
events/004.json: deployment
|
19
|
+
events/005.json: deployment_status
|
20
|
+
events/006.json: fork
|
21
|
+
...
|
22
|
+
```
|
23
|
+
|
24
|
+
Let's say you have a github _commit_comment_ event stored in a file `event.json`
|
25
|
+
|
26
|
+
```
|
27
|
+
% cat event.json | gh-event2text
|
28
|
+
...
|
29
|
+
```
|
30
|
+
|
31
|
+
## Installation
|
32
|
+
|
33
|
+
Add this line to your application's Gemfile:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
gem 'gh-events'
|
37
|
+
```
|
38
|
+
|
39
|
+
And then execute:
|
40
|
+
|
41
|
+
$ bundle
|
42
|
+
|
43
|
+
Or install it yourself as:
|
44
|
+
|
45
|
+
$ gem install gh-events
|
46
|
+
|
47
|
+
## References
|
48
|
+
|
49
|
+
- https://developer.github.com/v3/activity/events/types/
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
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.
|
54
|
+
|
55
|
+
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).
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/200ok-ch/gh-events.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "github/events"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/exe/gh-event2text
ADDED
data/exe/gh-events
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib = File.expand_path("../../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'gh/events'
|
7
|
+
|
8
|
+
ARGV.each do |file|
|
9
|
+
begin
|
10
|
+
type = GH::Events.typeof(File.read(file))
|
11
|
+
rescue
|
12
|
+
type = 'error'
|
13
|
+
end
|
14
|
+
puts "#{file}: #{type}"
|
15
|
+
end
|
data/gh-events.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "gh/events/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gh-events"
|
8
|
+
spec.version = GH::Events::VERSION
|
9
|
+
spec.authors = ["Phil Hofmann"]
|
10
|
+
spec.email = ["phil@200ok.ch"]
|
11
|
+
|
12
|
+
spec.summary = %q{Determine Github event types by their payload.}
|
13
|
+
spec.description = %q{Determine Github event types by their payload.}
|
14
|
+
spec.homepage = "https://github.com/200ok-ch/gh-events"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
23
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
24
|
+
else
|
25
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
26
|
+
"public gem pushes."
|
27
|
+
end
|
28
|
+
|
29
|
+
# Specify which files should be added to the gem when it is released.
|
30
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
32
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
+
end
|
34
|
+
spec.bindir = "exe"
|
35
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
+
spec.require_paths = ["lib"]
|
37
|
+
|
38
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
39
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
40
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
41
|
+
spec.add_development_dependency "rspec_junit_formatter", "~> 0.4"
|
42
|
+
end
|
data/lib/gh-events.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path(File.join(%w(.. gh events)), __FILE__)
|
data/lib/gh/events.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require "gh/events/version"
|
2
|
+
require "gh/events/text"
|
3
|
+
require 'hash'
|
4
|
+
|
5
|
+
require 'yaml'
|
6
|
+
require 'ostruct'
|
7
|
+
|
8
|
+
module GH
|
9
|
+
module Events
|
10
|
+
class Error < StandardError; end
|
11
|
+
|
12
|
+
extend self
|
13
|
+
|
14
|
+
PATH = File.expand_path(File.join(%w(.. .. .. res events.yml)), __FILE__)
|
15
|
+
HEURISTICS = YAML.load_file(PATH)
|
16
|
+
|
17
|
+
def typeof(payload)
|
18
|
+
payload = JSON.parse(payload) if payload.is_a?(String)
|
19
|
+
payload = payload.marshal_dump if payload.is_a?(OpenStruct)
|
20
|
+
payload = payload.deep_stringify_keys
|
21
|
+
keys = payload.keys
|
22
|
+
HEURISTICS.each do |type, characteristics|
|
23
|
+
# puts ("-" * 30) + " #{type}"
|
24
|
+
|
25
|
+
# all keys in `present` are there
|
26
|
+
x = ((characteristics['present'] || []) - keys)
|
27
|
+
next unless x.empty?
|
28
|
+
|
29
|
+
# non of the keys in `absent` are there
|
30
|
+
y = ((characteristics['absent'] || []) & keys)
|
31
|
+
next unless y.empty?
|
32
|
+
|
33
|
+
# everything in `exactly` is there including the values
|
34
|
+
z = payload.dup.merge(characteristics['exactly'] || {}) == payload
|
35
|
+
next unless z
|
36
|
+
|
37
|
+
n = characteristics['number_of_keys'] &&
|
38
|
+
keys.count != characteristics['number_of_keys']
|
39
|
+
next if n
|
40
|
+
|
41
|
+
return type.to_sym
|
42
|
+
end
|
43
|
+
return :unknown
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'erb'
|
3
|
+
require 'ostruct'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module GH::Events::Text
|
7
|
+
|
8
|
+
extend self
|
9
|
+
|
10
|
+
# this is a carefully curated list of fields in gh events that might
|
11
|
+
# be helpful when filtering events
|
12
|
+
ASPECTS = %i[type action state]
|
13
|
+
|
14
|
+
def translate(payload, dict)
|
15
|
+
dict ||= 'plain'
|
16
|
+
|
17
|
+
templates = YAML.load_file(templates_file(dict))
|
18
|
+
|
19
|
+
event = JSON.parse(payload, object_class: OpenStruct)
|
20
|
+
type = GH::Events.typeof(event).to_s
|
21
|
+
|
22
|
+
# unify
|
23
|
+
event.ref_type = 'branch' if event.ref&.match(/^refs\/heads\//)
|
24
|
+
event.ref_type = 'tag' if event.ref&.match(/^refs\/tags\//)
|
25
|
+
event.ref = event.ref&.split('/')&.last
|
26
|
+
|
27
|
+
# add type to the event
|
28
|
+
event.type = type
|
29
|
+
|
30
|
+
# collect the aspects
|
31
|
+
aspects = ASPECTS.map { |a| event.send(a) }.compact
|
32
|
+
|
33
|
+
# add the specific type (stype) to the event
|
34
|
+
event.stype = aspects * '.'
|
35
|
+
|
36
|
+
# lookup the template by type and all the specific types
|
37
|
+
_result = aspects.reduce({as: [], ts: []}) do |r, aspect|
|
38
|
+
r[:as] << aspect
|
39
|
+
r[:ts] << templates[r[:as] * '.']
|
40
|
+
r
|
41
|
+
end
|
42
|
+
template = _result[:ts].compact.last
|
43
|
+
|
44
|
+
# if the event was set to `false` abort
|
45
|
+
return nil if template === false
|
46
|
+
|
47
|
+
# if there is no template use a default
|
48
|
+
template ||= templates['no_template']
|
49
|
+
|
50
|
+
render(template, event)
|
51
|
+
end
|
52
|
+
|
53
|
+
def templates_file(dict)
|
54
|
+
preset = File.expand_path(File.join(%w(.. .. .. .. res) << "#{dict}.yml"), __FILE__)
|
55
|
+
return preset if File.exists?(preset)
|
56
|
+
|
57
|
+
return dict if File.exists?(dict.to_s)
|
58
|
+
|
59
|
+
warn "Could not find dict file: #{dict}"
|
60
|
+
exit(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
class ErbBinding < OpenStruct
|
64
|
+
def get_binding
|
65
|
+
return binding()
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def render(template, data)
|
70
|
+
ERB.new(JSON.unparse(template)).result(ErbBinding.new(data).get_binding)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
data/lib/hash.rb
ADDED
data/res/events.yml
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
---
|
2
|
+
# https://developer.github.com/v3/activity/events/types/
|
3
|
+
|
4
|
+
# the order is crucial, first match wins!
|
5
|
+
|
6
|
+
watch: # 49
|
7
|
+
present:
|
8
|
+
- action
|
9
|
+
- repository
|
10
|
+
exactly:
|
11
|
+
action: started
|
12
|
+
|
13
|
+
# check_run # 1
|
14
|
+
|
15
|
+
# check_suite # 2
|
16
|
+
|
17
|
+
commit_comment: # 3
|
18
|
+
present:
|
19
|
+
- comment
|
20
|
+
- repository
|
21
|
+
absent:
|
22
|
+
- issue
|
23
|
+
- pull_request
|
24
|
+
|
25
|
+
# content_reference # 4
|
26
|
+
|
27
|
+
create: # 5
|
28
|
+
present:
|
29
|
+
- ref_type
|
30
|
+
- ref
|
31
|
+
- master_branch
|
32
|
+
- description
|
33
|
+
- repository
|
34
|
+
|
35
|
+
delete: # 6
|
36
|
+
present:
|
37
|
+
- ref_type
|
38
|
+
- ref
|
39
|
+
- repository
|
40
|
+
absent:
|
41
|
+
- master_branch
|
42
|
+
|
43
|
+
# deploy_key # 7
|
44
|
+
|
45
|
+
deployment: # 8
|
46
|
+
present:
|
47
|
+
- deployment
|
48
|
+
- repository
|
49
|
+
absent:
|
50
|
+
- deployment_status
|
51
|
+
|
52
|
+
deployment_status: # 9
|
53
|
+
present:
|
54
|
+
- deployment
|
55
|
+
- deployment_status
|
56
|
+
- repository
|
57
|
+
|
58
|
+
# download # 10
|
59
|
+
|
60
|
+
# follow # 11
|
61
|
+
|
62
|
+
fork: # 12
|
63
|
+
present:
|
64
|
+
- forkee
|
65
|
+
- repository
|
66
|
+
|
67
|
+
# fork_apply # 13
|
68
|
+
|
69
|
+
# git_hub_app_authorization # 14
|
70
|
+
|
71
|
+
# gist # 15
|
72
|
+
|
73
|
+
gollum: # 16
|
74
|
+
present:
|
75
|
+
- pages
|
76
|
+
- repository
|
77
|
+
|
78
|
+
# installation: # 17
|
79
|
+
|
80
|
+
# installation_repositories: # 18
|
81
|
+
|
82
|
+
issue_comment: # 19
|
83
|
+
present:
|
84
|
+
- issue
|
85
|
+
- comment
|
86
|
+
- repository
|
87
|
+
|
88
|
+
issues: # 20
|
89
|
+
present:
|
90
|
+
- issue
|
91
|
+
- repository
|
92
|
+
absent:
|
93
|
+
- comment
|
94
|
+
|
95
|
+
# label # 21
|
96
|
+
|
97
|
+
# marketplace_purchase # 22
|
98
|
+
|
99
|
+
member: # 23
|
100
|
+
present:
|
101
|
+
- member
|
102
|
+
- repository
|
103
|
+
|
104
|
+
membership: # 24
|
105
|
+
present:
|
106
|
+
- scope
|
107
|
+
- member
|
108
|
+
- team
|
109
|
+
- organization
|
110
|
+
|
111
|
+
# meta # 25
|
112
|
+
|
113
|
+
# milestone # 26
|
114
|
+
|
115
|
+
# organization # 27
|
116
|
+
|
117
|
+
# org_block # 28
|
118
|
+
|
119
|
+
page_build: # 29
|
120
|
+
present:
|
121
|
+
- build
|
122
|
+
- repository
|
123
|
+
|
124
|
+
# project_card # 30
|
125
|
+
|
126
|
+
# project_column # 31
|
127
|
+
|
128
|
+
# project # 32
|
129
|
+
|
130
|
+
public: # 33
|
131
|
+
present:
|
132
|
+
- repository
|
133
|
+
number_of_keys: 2
|
134
|
+
|
135
|
+
pull_request: # 34
|
136
|
+
present:
|
137
|
+
- pull_request
|
138
|
+
- repository
|
139
|
+
absent:
|
140
|
+
- comment
|
141
|
+
|
142
|
+
# pull_request_review # 35
|
143
|
+
|
144
|
+
pull_request_review_comment: # 36
|
145
|
+
present:
|
146
|
+
- comment
|
147
|
+
- pull_request
|
148
|
+
- repository
|
149
|
+
|
150
|
+
push: # 37
|
151
|
+
present:
|
152
|
+
- ref
|
153
|
+
- before
|
154
|
+
- commits
|
155
|
+
- repository
|
156
|
+
|
157
|
+
# registry_package # 38
|
158
|
+
|
159
|
+
release: # 39
|
160
|
+
present:
|
161
|
+
- release
|
162
|
+
- repository
|
163
|
+
|
164
|
+
# repository_dispatch # 40
|
165
|
+
|
166
|
+
repository: # 41
|
167
|
+
present:
|
168
|
+
- action
|
169
|
+
- repository
|
170
|
+
number_of_keys: 3
|
171
|
+
|
172
|
+
# repository_import # 42
|
173
|
+
|
174
|
+
# repository_vulnerability_report # 43
|
175
|
+
|
176
|
+
# security_advisory # 44
|
177
|
+
|
178
|
+
star: # 45
|
179
|
+
present:
|
180
|
+
- starred_at
|
181
|
+
|
182
|
+
status: # 46
|
183
|
+
present:
|
184
|
+
- sha
|
185
|
+
- state
|
186
|
+
- description
|
187
|
+
- branches
|
188
|
+
|
189
|
+
# team # 47
|
190
|
+
|
191
|
+
team_add: # 48
|
192
|
+
present:
|
193
|
+
- team
|
194
|
+
- repository
|
data/res/plain.yml
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# All refs are unified. So all events have `ref` and `ref_type`.
|
2
|
+
# Additionally all events have `type` and `stype`.
|
3
|
+
|
4
|
+
push: >-
|
5
|
+
[<%= repository.full_name %>]
|
6
|
+
<%= sender.login %> <%= forced ? 'force-' : '' %>pushed
|
7
|
+
<% if ref_type == 'branch' %><%= num = size || commits.count %> commit<%= num > 1 ? 's' : '' %> to<% end %>
|
8
|
+
<%= ref_type %> `<%= ref %>`
|
9
|
+
|
10
|
+
commit_comment: >-
|
11
|
+
[<%= repository.full_name %>]
|
12
|
+
<%= sender.login %>
|
13
|
+
commented on
|
14
|
+
commit `<%= comment.commit_id %>`>: "<%= comment.body %>"
|
15
|
+
|
16
|
+
create: >-
|
17
|
+
[<%= repository.full_name %>]
|
18
|
+
<%= sender.login %>
|
19
|
+
created
|
20
|
+
<%= ref_type %> `<%= ref %>`
|
21
|
+
|
22
|
+
delete: >-
|
23
|
+
[<%= repository.full_name %>]
|
24
|
+
<%= sender.login %>
|
25
|
+
deleted
|
26
|
+
<%= ref_type %> `<%= ref %>`
|
27
|
+
|
28
|
+
issue_comment: >-
|
29
|
+
[<%= repository.full_name %>]
|
30
|
+
<%= sender.login %>
|
31
|
+
commented
|
32
|
+
on issue "<%= issue.title %>": <%= comment.body %>
|
33
|
+
|
34
|
+
issues: >-
|
35
|
+
[<%= repository.full_name %>]
|
36
|
+
<%= sender.login %>
|
37
|
+
<%= action %>
|
38
|
+
issue "<%= issue.title %>"
|
39
|
+
|
40
|
+
issues.opened: >-
|
41
|
+
[<%= repository.full_name %>]
|
42
|
+
<%= sender.login %>
|
43
|
+
create the issue
|
44
|
+
"<%= issue.title %>": <%= repository.html_url %>
|
45
|
+
|
46
|
+
issues.labeled: >-
|
47
|
+
[<%= repository.full_name %>]
|
48
|
+
<%= sender.login %>
|
49
|
+
labeled
|
50
|
+
issue "<%= issue.title %>"
|
51
|
+
as `<%= label.name %>`
|
52
|
+
|
53
|
+
pull_request: >-
|
54
|
+
[<%= repository.full_name %>]
|
55
|
+
<%= sender.login %>
|
56
|
+
<%= action %>
|
57
|
+
PR "<%= pull_request.title %>"
|
58
|
+
|
59
|
+
pull_request.opened: >-
|
60
|
+
[<%= repository.full_name %>]
|
61
|
+
<%= sender.login %>
|
62
|
+
opened
|
63
|
+
PR <%= pull_request.title %>: <%= pull_request.body %>
|
64
|
+
|
65
|
+
pull_request.labeled: >-
|
66
|
+
[<%= repository.full_name %>]
|
67
|
+
<%= sender.login %>
|
68
|
+
labeled
|
69
|
+
PR "<%= pull_request.title %>"
|
70
|
+
as `<%= label.name %>`
|
71
|
+
|
72
|
+
pull_request_review_comment: >-
|
73
|
+
[<%= repository.full_name %>]
|
74
|
+
<%= sender.login %>
|
75
|
+
reviewed: <%= comment.body %>
|
76
|
+
|
77
|
+
star: >-
|
78
|
+
[<%= repository.full_name %>]
|
79
|
+
<%= sender.login %>
|
80
|
+
<%= action == 'created' ? 'starred' : 'unstarred' %>
|
81
|
+
<%= repository.full_name %>
|
82
|
+
(<%= repository.stargazers_count %>)
|
83
|
+
|
84
|
+
# Ignore other status udpates than CircleCI failures for the moment
|
85
|
+
status: false
|
86
|
+
|
87
|
+
status.failure: >-
|
88
|
+
[<%= repository.full_name %>]
|
89
|
+
CircleCI build failed
|
90
|
+
for commit "<%= commit.commit.message %>"
|
91
|
+
by "<%= sender.login %>"
|
92
|
+
|
93
|
+
fork: >-
|
94
|
+
[<%= repository.full_name %>]
|
95
|
+
<%= sender.login %>
|
96
|
+
forked <%= repository.full_name %>
|
97
|
+
(<%= repository.forks_count %>)
|
98
|
+
|
99
|
+
deployment: An event of type `deployment` occurred.
|
100
|
+
deployment_status: An event of type `deployment_status` occurred.
|
101
|
+
gollum: An event of type `gollum` occurred.
|
102
|
+
member: An event of type `member` occurred.
|
103
|
+
membership: An event of type `membership` occurred.
|
104
|
+
page_build: An event of type `page_build` occurred.
|
105
|
+
public: An event of type `public` occurred.
|
106
|
+
release: An event of type `release` occurred.
|
107
|
+
repository: An event of type `repository` occurred.
|
108
|
+
team_add: An event of type `team_add` occurred.
|
109
|
+
|
110
|
+
# `false` will make it end with exit code 1
|
111
|
+
watch: false
|
112
|
+
|
113
|
+
# `no_template` will be used for recognized events which have no
|
114
|
+
# template assigned.
|
115
|
+
no_template: No template for event of type `<%= type %>` (`<%= stype %>`).
|
116
|
+
|
117
|
+
# `unknown` will be used for events that could not be recognized.
|
118
|
+
unknown: "An unknown event occurred (stype: `<%= stype %>`)"
|
data/res/slack.yml
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
# refs are unified. So all events have `ref` and `ref_type`.
|
2
|
+
|
3
|
+
push:
|
4
|
+
text: >-
|
5
|
+
:arrow_up:
|
6
|
+
<<%= sender.html_url %>|<%= sender.login %>>
|
7
|
+
<%= forced ? 'force-' : '' %>pushed
|
8
|
+
<% if ref_type == 'branch' %><%= num = size || commits.count %> commit<%= num > 1 ? 's' : '' %> to<% end %>
|
9
|
+
<%= ref_type %> `<%= ref %>`
|
10
|
+
on <<%= repository.html_url %>|<%= repository.full_name %>>
|
11
|
+
(<<%= compare %>|compare>)
|
12
|
+
|
13
|
+
commit_comment:
|
14
|
+
text: >-
|
15
|
+
:left_speech_bubble:
|
16
|
+
new comment for
|
17
|
+
commit <<%= comment.html_url %>|`<%= comment.commit_id %>`>
|
18
|
+
on <<%= repository.html_url %>|<%= repository.full_name %>>
|
19
|
+
attachments:
|
20
|
+
- fallback: <%= comment.body %>
|
21
|
+
color: '#36a64f'
|
22
|
+
# pretext: Optional text that appears above the attachment block
|
23
|
+
author_name: <%= sender.login %>
|
24
|
+
author_link: <%= sender.html_url %>
|
25
|
+
author_icon: <%= sender.avatar_url %>
|
26
|
+
# title: Slack API Documentation
|
27
|
+
# title_link: https://api.slack.com/
|
28
|
+
text: <%= comment.body %>
|
29
|
+
# fields:
|
30
|
+
# - title: Priority
|
31
|
+
# value: High
|
32
|
+
# short: false
|
33
|
+
# image_url: http://my-website.com/path/to/image.jpg
|
34
|
+
# thumb_url: http://example.com/path/to/thumb.png
|
35
|
+
# footer: Slack API
|
36
|
+
# footer_icon: https://platform.slack-edge.com/img/default_application_icon.png
|
37
|
+
# ts: 123456789
|
38
|
+
|
39
|
+
create:
|
40
|
+
text: >-
|
41
|
+
:sparkles:
|
42
|
+
<<%= sender.html_url %>|<%= sender.login %>>
|
43
|
+
created
|
44
|
+
<%= ref_type %> `<%= ref %>`
|
45
|
+
on <<%= repository.html_url %>|<%= repository.full_name %>>
|
46
|
+
|
47
|
+
delete:
|
48
|
+
text: >-
|
49
|
+
:wastebasket:
|
50
|
+
<<%= sender.html_url %>|<%= sender.login %>>
|
51
|
+
deleted
|
52
|
+
<%= ref_type %> `<%= ref %>`
|
53
|
+
on <<%= repository.html_url %>|<%= repository.full_name %>>
|
54
|
+
|
55
|
+
issue_comment:
|
56
|
+
text: >-
|
57
|
+
:left_speech_bubble:
|
58
|
+
<<%= sender.html_url %>|<%= sender.login %>>
|
59
|
+
commented
|
60
|
+
on <<%= comment.html_url %>|<%= issue.title %>>
|
61
|
+
attachments:
|
62
|
+
- fallback: <%= comment.body %>
|
63
|
+
color: '#36a64f'
|
64
|
+
author_name: <%= sender.login %>
|
65
|
+
author_link: <%= sender.html_url %>
|
66
|
+
author_icon: <%= sender.avatar_url %>
|
67
|
+
text: <%= comment.body %>
|
68
|
+
|
69
|
+
issues:
|
70
|
+
text: >-
|
71
|
+
:inbox_tray:
|
72
|
+
<<%= sender.html_url %>|<%= sender.login %>>
|
73
|
+
<%= action %>
|
74
|
+
issue <<%= issue.html_url %>|<%= issue.title %>>
|
75
|
+
on <<%= repository.html_url %>|<%= repository.full_name %>>
|
76
|
+
|
77
|
+
issues.opened:
|
78
|
+
text: >-
|
79
|
+
:inbox_tray:
|
80
|
+
new issue
|
81
|
+
<<%= issue.html_url %>|<%= issue.title %>>
|
82
|
+
on <<%= repository.html_url %>|<%= repository.full_name %>>
|
83
|
+
attachments:
|
84
|
+
- fallback: <%= issue.body %>
|
85
|
+
color: red
|
86
|
+
author_name: <%= sender.login %>
|
87
|
+
author_link: <%= sender.html_url %>
|
88
|
+
author_icon: <%= sender.avatar_url %>
|
89
|
+
text: <%= issue.body %>
|
90
|
+
|
91
|
+
issues.labeled:
|
92
|
+
text: >-
|
93
|
+
:label:
|
94
|
+
<<%= sender.html_url %>|<%= sender.login %>>
|
95
|
+
labeled
|
96
|
+
issue <<%= issue.html_url %>|<%= issue.title %>>
|
97
|
+
on <<%= repository.html_url %>|<%= repository.full_name %>>
|
98
|
+
as `<%= label.name %>`
|
99
|
+
|
100
|
+
pull_request:
|
101
|
+
text: >-
|
102
|
+
:gift:
|
103
|
+
<<%= sender.html_url %>|<%= sender.login %>>
|
104
|
+
<%= action %>
|
105
|
+
PR <<%= pull_request.html_url %>|<%= pull_request.title %>>
|
106
|
+
on <<%= repository.html_url %>|<%= repository.full_name %>>
|
107
|
+
|
108
|
+
pull_request.opened:
|
109
|
+
text: >-
|
110
|
+
:gift:
|
111
|
+
<<%= sender.html_url %>|<%= sender.login %>>
|
112
|
+
opened
|
113
|
+
PR <<%= pull_request.html_url %>|<%= pull_request.title %>>
|
114
|
+
on <<%= repository.html_url %>|<%= repository.full_name %>>
|
115
|
+
attachments:
|
116
|
+
- fallback: <%= pull_request.body %>
|
117
|
+
color: red
|
118
|
+
author_name: <%= sender.login %>
|
119
|
+
author_link: <%= sender.html_url %>
|
120
|
+
author_icon: <%= sender.avatar_url %>
|
121
|
+
text: <%= pull_request.body %>
|
122
|
+
|
123
|
+
pull_request.labeled:
|
124
|
+
text: >-
|
125
|
+
<<%= sender.html_url %>|<%= sender.login %>>
|
126
|
+
labeled
|
127
|
+
PR <<%= pull_request.html_url %>|<%= pull_request.title %>>
|
128
|
+
on <<%= repository.html_url %>|<%= repository.full_name %>>
|
129
|
+
as `<%= label.name %>`
|
130
|
+
|
131
|
+
pull_request_review_comment:
|
132
|
+
text: >-
|
133
|
+
:left_speech_bubble:
|
134
|
+
new review comment
|
135
|
+
on <<%= comment.html_url %>|<%= pull_request.title %>>
|
136
|
+
attachments:
|
137
|
+
- fallback: <%= comment.body %>
|
138
|
+
color: red
|
139
|
+
author_name: <%= sender.login %>
|
140
|
+
author_link: <%= sender.html_url %>
|
141
|
+
author_icon: <%= sender.avatar_url %>
|
142
|
+
text: <%= comment.body %>
|
143
|
+
|
144
|
+
star:
|
145
|
+
text: >-
|
146
|
+
:star:
|
147
|
+
<<%= sender.html_url %>|<%= sender.login %>>
|
148
|
+
<%= action == 'created' ? 'starred' : 'unstarred' %>
|
149
|
+
<<%= repository.html_url %>|<%= repository.full_name %>>
|
150
|
+
:star: <%= repository.stargazers_count %>
|
151
|
+
|
152
|
+
# Ignore other status udpates than CircleCI failures for the moment
|
153
|
+
status: false
|
154
|
+
|
155
|
+
status.failure:
|
156
|
+
text: >-
|
157
|
+
<<%= target_url %> | CircleCI build >
|
158
|
+
fails for commit
|
159
|
+
<<%= commit.html_url %> | <%= commit.commit.message %>>
|
160
|
+
from
|
161
|
+
<<%= sender.html_url %>|<%= sender.login %>>
|
162
|
+
|
163
|
+
fork:
|
164
|
+
text: >-
|
165
|
+
:fork_and_knife:
|
166
|
+
<<%= sender.html_url %>|<%= sender.login %>>
|
167
|
+
forked <<%= repository.html_url %>|<%= repository.full_name %>>
|
168
|
+
:fork_and_knife: <%= repository.forks_count %>
|
169
|
+
|
170
|
+
deployment:
|
171
|
+
text: An event of type `deployment` occurred.
|
172
|
+
deployment_status:
|
173
|
+
text: An event of type `deployment_status` occurred.
|
174
|
+
gollum:
|
175
|
+
text: An event of type `gollum` occurred.
|
176
|
+
member:
|
177
|
+
text: An event of type `member` occurred.
|
178
|
+
membership:
|
179
|
+
text: An event of type `membership` occurred.
|
180
|
+
page_build:
|
181
|
+
text: An event of type `page_build` occurred.
|
182
|
+
public:
|
183
|
+
text: An event of type `public` occurred.
|
184
|
+
release:
|
185
|
+
text: An event of type `release` occurred.
|
186
|
+
repository:
|
187
|
+
text: An event of type `repository` occurred.
|
188
|
+
team_add:
|
189
|
+
text: An event of type `team_add` occurred.
|
190
|
+
|
191
|
+
# `false` will make it end with exit code 1
|
192
|
+
watch: false
|
193
|
+
|
194
|
+
# `no_template` will be used for recognized events which have no
|
195
|
+
# template assigned.
|
196
|
+
no_template:
|
197
|
+
text: No template for event of type `<%= stype %>`.
|
198
|
+
attachments:
|
199
|
+
- fallback: Event details as json.
|
200
|
+
color: gray
|
201
|
+
text: |
|
202
|
+
```
|
203
|
+
<%= JSON.unparse(self.marshal_dump) %>
|
204
|
+
```
|
205
|
+
|
206
|
+
# `unknown` will be used for events that could not be recognized.
|
207
|
+
unknown:
|
208
|
+
text: "An unknown event occurred (stype: `<%=stype%>`)"
|
209
|
+
attachments:
|
210
|
+
- fallback: Event details as json.
|
211
|
+
color: gray
|
212
|
+
text: |
|
213
|
+
```
|
214
|
+
<%= JSON.unparse(self.marshal_dump) %>
|
215
|
+
```
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gh-events
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Phil Hofmann
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec_junit_formatter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.4'
|
69
|
+
description: Determine Github event types by their payload.
|
70
|
+
email:
|
71
|
+
- phil@200ok.ch
|
72
|
+
executables:
|
73
|
+
- gh-event2text
|
74
|
+
- gh-events
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".circleci/config.yml"
|
79
|
+
- ".gitignore"
|
80
|
+
- ".rspec"
|
81
|
+
- ".ruby-version"
|
82
|
+
- Gemfile
|
83
|
+
- Gemfile.lock
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/console
|
87
|
+
- bin/setup
|
88
|
+
- exe/gh-event2text
|
89
|
+
- exe/gh-events
|
90
|
+
- gh-events.gemspec
|
91
|
+
- lib/gh-events.rb
|
92
|
+
- lib/gh/events.rb
|
93
|
+
- lib/gh/events/text.rb
|
94
|
+
- lib/gh/events/version.rb
|
95
|
+
- lib/hash.rb
|
96
|
+
- res/events.yml
|
97
|
+
- res/plain.yml
|
98
|
+
- res/slack.yml
|
99
|
+
homepage: https://github.com/200ok-ch/gh-events
|
100
|
+
licenses: []
|
101
|
+
metadata:
|
102
|
+
homepage_uri: https://github.com/200ok-ch/gh-events
|
103
|
+
source_code_uri: https://github.com/200ok-ch/gh-events
|
104
|
+
changelog_uri: https://github.com/200ok-ch/gh-events
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubygems_version: 3.0.3
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Determine Github event types by their payload.
|
124
|
+
test_files: []
|