Giter Club home page Giter Club logo

hubot-github-repo-event-notifier's Introduction

Hubot: hubot-github-repo-event-notifier

Notifies about any available GitHub repo event via webhook.

See src/github-repo-event-notifier.coffee for full documentation.

Installation

Add hubot-github-repo-event-notifier to your package.json file:

"dependencies": {
  "hubot": ">= 2.5.1",
  "hubot-scripts": ">= 2.4.2",
  "hubot-github-repo-event-notifier": ">= 0.0.0",
  "hubot-hipchat": "~2.5.1-5",
}

Add hubot-github-repo-event-notifier to your external-scripts.json:

["hubot-github-repo-event-notifier"]

Run npm install

When starting hubot you need to specify the events it will accept. This is done via the HUBOT_GITHUB_EVENT_NOTIFIER_TYPES

Ex:

HUBOT_GITHUB_EVENT_NOTIFIER_TYPES=pull_request,pull_request

If you want you can specific events in the event types.

Ex:

HUBOT_GITHUB_EVENT_NOTIFIER_TYPES=pull_request:comment,pull_request:close

Development Testing

Ideally, you'd write tests and put them in our test/ directory.

If you just want to mess around with some things, we've bundled a REPL for you which has some fixture data and exposes the core functionality of the processing of events. To boot up the reply, launch script/console.

  • Sample payloads are available via the variable eventPayloads. It contains a key for each event type, e.g. pull_request or page_build.
  • Each processing function is available via actions. This object contains a key for each event type, e.g. pull_request or page_build. It takes the payload object and the callback function as its parameters, in that order.

hubot-github-repo-event-notifier's People

Contributors

csanner avatar florasaramago avatar geekgonecrazy avatar martinb3 avatar msabramo avatar parkr avatar patcon avatar strugee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hubot-github-repo-event-notifier's Issues

Display issue/PR titles

Issue/PR titles aren't outputted; instead, only the number is put in the room which isn't very helpful. We should fix this.

Add a `pull_request:merged` event

Subset of #9

payload for closed PR:
https://gist.github.com/patcon/11215810#file-closed-pull-request-json

{
//...
  "merged": false,
  "mergeable": true,
  "mergeable_state": "clean",
  "merged_by": null,
/...
}

payload for a merged PR:
https://gist.github.com/patcon/11215810#file-merged-pull-request-json

{
//...
  "merged": true,
  "mergeable": null,
  "mergeable_state": "unknown",
  "merged_by": {
    "login": "whit537",
    "id": 134455,
    "avatar_url": "https://avatars.githubusercontent.com/u/134455?",
    "gravatar_id": "fb054b407a6461e417ee6b6ae084da37",
//...
}

SyntaxError: reserved word "function"

Using version 1.5.0, I get this error:

hubot> [Fri Sep 18 2015 22:48:49 GMT-0400 (EDT)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Fri Sep 18 2015 22:48:49 GMT-0400 (EDT)] ERROR Unable to load /Users/gableroux/repos/hubot/node_modules/hubot-github-repo-event-notifier/src/github-repo-event-notifier: SyntaxError: reserved word "function"
  at exports.throwSyntaxError (/Users/gableroux/repos/hubot/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/helpers.js:197:13)
  at Lexer.exports.Lexer.Lexer.error (/Users/gableroux/repos/hubot/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/lexer.js:778:14)
  at Lexer.exports.Lexer.Lexer.identifierToken (/Users/gableroux/repos/hubot/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/lexer.js:102:16)
  at Lexer.exports.Lexer.Lexer.tokenize (/Users/gableroux/repos/hubot/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/lexer.js:30:25)
  at exports.compile.compile (/Users/gableroux/repos/hubot/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/coffee-script.js:35:36)
  at Object.loadFile (/Users/gableroux/repos/hubot/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/coffee-script.js:176:14)
  at Module.load (/Users/gableroux/repos/hubot/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/coffee-script.js:211:36)
  at Function.Module._load (module.js:310:12)
  at Module.require (module.js:365:17)
  at require (module.js:384:17)
  at Robot.loadFile (/Users/gableroux/repos/hubot/node_modules/hubot/src/robot.coffee:250:9, <js>:175:20)
  at /Users/gableroux/repos/hubot/node_modules/hubot-github-repo-event-notifier/index.coffee:12:11, <js>:26:33
  at FSReqWrap.cb [as oncomplete] (fs.js:226:19)

I've switched to 1.4.0 and didn't get the error.

Can get PRs but not new Issues

There may be a mixup between 'issue' and 'issues' somewhere. GitHub webhook sends out "issues" as the event type, but I think the script may look for "issue".

Also, I'd like to add support for other types of hooks that go out, is it as simple as just doing a PR against all.coffee?

ReferenceError: robot is not defined

When I use hubot-github-repo-event-notifier version 1.8 I get the following error when I start my hubot instance.

ERROR Unable to load /app/node_modules/hubot-github-repo-event-notifier/src/github-repo-event-notifier: ReferenceError: robot is not defined
at Object.<anonymous> (/app/node_modules/hubot-github-repo-event-notifier/src/github-repo-event-notifier.coffee:61:3, <js>:33:5)
at Object.<anonymous> (/app/node_modules/hubot-github-repo-event-notifier/src/github-repo-event-notifier.coffee:37:1, <js>:90:4)
at Module._compile (module.js:570:32)
at Object.loadFile (/app/node_modules/coffee-script/lib/coffee-script/coffee-script.js:182:19)
at Module.load (/app/node_modules/coffee-script/lib/coffee-script/coffee-script.js:211:36)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Robot.loadFile (/app/node_modules/hubot/src/robot.coffee:355:9, <js>:224:20)
at /app/node_modules/hubot-github-repo-event-notifier/index.coffee:12:11, <js>:26:33
at FSReqWrap.cb [as oncomplete] (fs.js:258:19)

This error occurs when I am running version 1.8.0. If I switch to 1.7.0, everything works fine on startup. The dangers of using version >= 0.0.0 in my package.json I suppose.

Anyways, I am running on OSX, but have tested this both inside a docker container as well as natively with the same result.

Custom Actions

I would like to trigger a custom action on release event type, in order to print the body text & release name with markdown. What's the best approach for overriding eventActions = require('./event-actions/all')

Cheers!

Add webhook via hubot command

/notify me <repo> [events]
  • repo is something like parkr/my_repo, or just my_repo if you've set HUBOT_GITHUB_ORG. Let's use githubot's built-in #qualified_repo function for this
  • events is optional and is a comma-separated list of events. Could also be all to specify all events.

Your hubot will require admin access to the repo in order to do this.

Event Type not recognized...

Just started a new hubot project, enabled the notifier and tried to simulate a Github webhook with Postman using the example payloads as specified by Github documentation (https://developer.github.com/v3/activity/events/types/#pullrequestevent).
The script skips the event with the message:

[Fri Jul 13 2018 11:45:53 GMT+0200 (Central European Summer Time)] DEBUG github-repo-event-notifier: Processing event type: "undefined"...
Ignoring undefined:closed as it's not allowed.
"dependencies": {
    "hubot": "^2.19.0",
    "hubot-diagnostics": "0.0.2",
    "hubot-help": "^0.2.2",
    "hubot-maps": "0.0.3",
    "hubot-redis-brain": "0.0.4",
    "hubot-scripts": "^2.17.2",
    "hubot-slack": "^4.5.2",
    "hubot-github-repo-event-notifier": ">= 1.8.1"
  },

Recognize self-assignments

I just got a notification about a PR which said "PR 1524 assigned to: strugee by strugee". It'd be more helpful if it said "PR 1524 self-assigned by strugee" instead.

please support wildcard event

Quote from https://developer.github.com/webhooks/#wildcard-event

We also support a wildcard (*) that will match all supported events. When you add the wildcard event, we’ll replace any existing events you have configured with the wildcard event and send you payloads for all supported events. You’ll also automatically get any new events we might add in the future.

Event type calculation is performed via

      if eventType in eventTypes

So setting HUBOT_GITHUB_EVENT_NOTIFIER_TYPES to *, as GitHub documentation suggests, has currently no effect.

Allow `event_type:action` format for enabling notifications

Right now, we're checking for "action": "opened" in the payload, and then checking for a key with the enabled event types (from HUBOT_GITHUB_EVENT_NOTIFIER_TYPES).

Just realized that we could instead expect the format for the envvar to be:

HUBOT_GITHUB_EVENT_NOTIFIER_TYPES="issue:opened,pull_request:opened"

Perhaps we could default to the opened action if not specified (and down the line, perhaps have a hash specifying the default for each type).

Release v1.7.0

Hey @patcon! It would be wonderful if you could release a v1.7.0. It contains #34 and would be a wonderful addition to the library. Alternatively, you could give me publishing abilities on NPM. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.