github.com/nektos/act@v0.2.63/pkg/runner/testdata/actions/node12/node_modules/@actions/github/lib/context.js (about) 1 "use strict"; 2 Object.defineProperty(exports, "__esModule", { value: true }); 3 exports.Context = void 0; 4 const fs_1 = require("fs"); 5 const os_1 = require("os"); 6 class Context { 7 /** 8 * Hydrate the context from the environment 9 */ 10 constructor() { 11 this.payload = {}; 12 if (process.env.GITHUB_EVENT_PATH) { 13 if (fs_1.existsSync(process.env.GITHUB_EVENT_PATH)) { 14 this.payload = JSON.parse(fs_1.readFileSync(process.env.GITHUB_EVENT_PATH, { encoding: 'utf8' })); 15 } 16 else { 17 const path = process.env.GITHUB_EVENT_PATH; 18 process.stdout.write(`GITHUB_EVENT_PATH ${path} does not exist${os_1.EOL}`); 19 } 20 } 21 this.eventName = process.env.GITHUB_EVENT_NAME; 22 this.sha = process.env.GITHUB_SHA; 23 this.ref = process.env.GITHUB_REF; 24 this.workflow = process.env.GITHUB_WORKFLOW; 25 this.action = process.env.GITHUB_ACTION; 26 this.actor = process.env.GITHUB_ACTOR; 27 this.job = process.env.GITHUB_JOB; 28 this.runNumber = parseInt(process.env.GITHUB_RUN_NUMBER, 10); 29 this.runId = parseInt(process.env.GITHUB_RUN_ID, 10); 30 } 31 get issue() { 32 const payload = this.payload; 33 return Object.assign(Object.assign({}, this.repo), { number: (payload.issue || payload.pull_request || payload).number }); 34 } 35 get repo() { 36 if (process.env.GITHUB_REPOSITORY) { 37 const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/'); 38 return { owner, repo }; 39 } 40 if (this.payload.repository) { 41 return { 42 owner: this.payload.repository.owner.login, 43 repo: this.payload.repository.name 44 }; 45 } 46 throw new Error("context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'"); 47 } 48 } 49 exports.Context = Context; 50 //# sourceMappingURL=context.js.map