@dapplion/benchmark
Version:
Ensures that new code does not introduce performance regressions with CI. Tracks:
28 lines (27 loc) • 894 B
JavaScript
import fs from "node:fs";
/**
* Github actions store the event data payload at a JSON file with path
* process.env.GITHUB_EVENT_PATH
*
* For example: '/home/runner/work/_temp/_github_workflow/event.json'
*
* The contents of the file are event dependant and equal to this docs
* https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/webhook-events-and-payloads#webhook-payload-object-5
*
* For example (on delete):
*
* {
* "pusher_type": "user",
* "ref": "dapplion/branch-to-delete",
* "ref_type": "branch",
* "repository": { ... },
* "organization": { ... },
* "sender": { ... }
* }
*/
export function getGithubEventData() {
if (!process.env.GITHUB_EVENT_PATH) {
throw Error("Not in a Github Actions context, no GITHUB_EVENT_PATH");
}
return JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8"));
}