@mheap/action-router
Route your GitHub Actions events to the correct handler
Last updated 6 months ago by mheap .
MIT · Original npm · Tarball · package.json
$ cnpm install @mheap/action-router 
SYNC missed versions from official npm registry.

Action Router

Handle multiple events in your GitHub Action with ease!

Installation

npm install @mheap/action-router --save

Usage

The router will look for keys that match the event type e.g. pull_request and the subtype e.g. opened and execute any functions listed.

If a pull request was opened with the following configuration, pull_request and pull_request.opened would run.

const router = require("@mheap/action-router");
const allPrAction = require("./allPrs");
const labelAction = require("./label");
const openAction = require("./open");

router({
  "pull_request": [allPrAction],
  "pull_request.opened": [openAction],
  "pull_request.labeled": [labelAction]
});

You can even run multiple methods in response to an event:

router({
  "pull_request.opened": [
    openAction, 
    () => { console.log("This runs too") }
  ]
});

If you need to pass any data to each called method, you can specify it as the second parameter in router:

router({
  "pull_request.opened": [
    openAction,
    () => { console.log("This runs too") }
  ]
}, [someVar, "strings-too"]);

Current Tags

  • 1.2.0                                ...           latest (6 months ago)

3 Versions

  • 1.2.0                                ...           6 months ago
  • 1.1.0                                ...           6 months ago
  • 1.0.0                                ...           6 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |