mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2024-11-24 14:51:01 -05:00
38 lines
No EOL
1.4 KiB
JavaScript
38 lines
No EOL
1.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
class Context {
|
|
/**
|
|
* Hydrate the context from the environment
|
|
*/
|
|
constructor() {
|
|
this.payload = process.env.GITHUB_EVENT_PATH
|
|
? require(process.env.GITHUB_EVENT_PATH)
|
|
: {};
|
|
this.eventName = process.env.GITHUB_EVENT_NAME;
|
|
this.sha = process.env.GITHUB_SHA;
|
|
this.ref = process.env.GITHUB_REF;
|
|
this.workflow = process.env.GITHUB_WORKFLOW;
|
|
this.action = process.env.GITHUB_ACTION;
|
|
this.actor = process.env.GITHUB_ACTOR;
|
|
}
|
|
get issue() {
|
|
const payload = this.payload;
|
|
return Object.assign({}, this.repo, { number: (payload.issue || payload.pullRequest || payload).number });
|
|
}
|
|
get repo() {
|
|
if (process.env.GITHUB_REPOSITORY) {
|
|
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
|
|
return { owner, repo };
|
|
}
|
|
if (this.payload.repository) {
|
|
return {
|
|
owner: this.payload.repository.owner.login,
|
|
repo: this.payload.repository.name
|
|
};
|
|
}
|
|
throw new Error("context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'");
|
|
}
|
|
}
|
|
exports.Context = Context;
|
|
//# sourceMappingURL=context.js.map
|