action-guard
Ensure that your GitHub Action has been triggered with the correct event and payload
Last updated 5 months ago by mheap .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install action-guard 
SYNC missed versions from official npm registry.

Action Guard

Make sure that your GitHub Actions are only running on events that you're expecting.

Replaces:

const event = process.env.GITHUB_EVENT_NAME;
const payload = require(process.env.GITHUB_EVENT_PATH);

if (event != "pull_request" || payload.action != "closed") {
  console.log(`
    This action only runs on pull_request.closed
    Found: ${event}.${payload.action}
  `);
  return;
}

With:

require("action-guard")("pull_request.closed");

Installation

npm install action-guard

Usage

Action Guard will throw an error if the GITHUB_EVENT_NAME does not match what is expected

If you're happy to leave it uncaught (leading to a process.exit(1)) you can add it as one line:

require("action-guard")("pull_request.closed");

Alternatively, you can wrap it in a try/catch

const guard = require("action-guard");

try {
  guard("pull_request.closed");
} catch (e) {
  // It didn't match. Let's do something else
}

Current Tags

  • 0.1.0                                ...           latest (5 months ago)

1 Versions

  • 0.1.0                                ...           5 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 (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |