Skip to content

Handle multiple GitHub Actions events in a single action

Notifications You must be signed in to change notification settings

mheap/action-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"]);

About

Handle multiple GitHub Actions events in a single action

Resources

Stars

Watchers

Forks

Packages

No packages published