Skip to content

Extensibility #3

Closed
Closed
@williamkapke

Description

@williamkapke

The path I was going was to use @rvagg's github-webhook-handler which sets things up in an evented way: when hook data comes in, emit the event. I took it a step further to emit event+'.'+action for more granularity.

I created a scripts directory where scripts could be added and they can listen to whatever events they need.

Here is echo.js that I created as an example:

var github = require('../github.js');

module.exports = function (org) {

  org.on('issue_comment.created', event=>{
    //this would be circular if we don't ignore ourself!
    if(!event.sender || !github.me || event.sender.id===github.me.id) return;

    var repo = event.repository;
    github.issues.createComment({
      user: repo.owner.login,
      repo: repo.name,
      number: event.issue.number,
      body: event.comment.body
    })
  });

};

How do you feel about going this route? It looks like the work in pollTravis could be done with this approach.

But, that was just my approach... ;) What way(s) do you see extending this to include other scripts/workers?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions