npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@viddsee/hubot-github-webhook-listener

v1.0.1

Published

Listens for github webhooks and emits an event for other Hubot scripts to respond to.

Downloads

4

Readme

hubot-github-webhook-listener

A Hubot script to that makes it easy to consume Github Webhooks.

Installation

From your hubot folder: npm install --save hubot-github-webhook-listener

Then, in your external-scripts.json file, add: "hubot-github-webhook-listener" to the list.

Create a new webhook for your myuser/myrepo repository at: https://github.com/myuser/myrepo/settings/hooks/new Set the webhook url to: <HUBOT_URL>:<PORT>/hubot/github-repo-listener

For example, if your hubot lives at myhubot.herokuapp.com, then you will set the webhook URL to: http://myhubot.herokuapp.com/hubot/github-repo-listener

Usage

On every incoming webhook message, a hubot event is emitted as follows

eventBody =
  eventType   : req.headers["x-github-event"]
  signature   : req.headers["X-Hub-Signature"]
  deliveryId  : req.headers["X-Github-Delivery"]
  payload     : req.body
  query       : querystring.parse(url.parse(req.url).query)

robot.emit "github-repo-event", eventBody

For details on these fields, see the Github Webhook documentation.

Securing Your Webhooks

To ensure non-github sources cannot send messages to your hubot, set an environment variable named GITHUB_WEBHOOK_SECRET to your Github hooks secret.

Consuming the event

You can consume it like so from one of your scripts:

@robot.on "github-repo-event", (repo_event) =>
  githubPayload = repo_event.payload
  switch(repo_event.eventType)
    when "issue_comment"
      ...

NOTE: This script does not emit anything in chat. It is just a background task that makes consuming Github webhooks easier for other scripts.

For another example, see our Hubot-Github adapter that gives you a hubot in your Github issue comments.

Motivation

I was using hubot-github-repo-event-notifier, but I needed something more generic to power our hubot-github adapter. So, I gutted it, and this script was born.

Local Testing

For easy local testing, I highly recommend ngrok: https://ngrok.com/

  1. Install ngrok
  2. run ngrok: ngrok 8080. It will show you a public URL like: Forwarding https://7a008da9.ngrok.com -> 127.0.0.1:8080
  3. Put that URL in as your Github webhook: https://7a008da9.ngrok.com/hubot/github-repo-listener
  4. Install the hubot-github adapter npm install --save hubot-github-adapter
  5. Run hubot locally: HUBOT_GITHUB_TOKEN=some_long_guid GITHUB_WEBHOOK_SECRET=some_secret bin/hubot -a github-adapter --name Hubot
  6. Fire off a github event by interacting with your repo. Comment on an issue or a PR for example.
  7. Navigate to http://127.0.0.1:4040/ There you can see all webhooks posted to your local machine, and can replay them as many times as you wish.

Copyright

Copyright © YouNeedABudget.com, LLC. (Github: YNAB)

Author

Taylor Brown, aka Taytay

License

MIT License; see LICENSE for further details.