forked from probot/adapter-github-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (22 loc) · 908 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
process.env.DISABLE_WEBHOOK_EVENT_CHECK = 'true';
const path = require('path');
const uuid = require('uuid');
const core = require('@actions/core');
const { Probot } = require('probot');
module.exports = (...handlers) => {
// Setup Probot app
const githubToken = process.env.GITHUB_TOKEN;
const probot = new Probot({ githubToken });
probot.setup(handlers);
// Process the event
const event = process.env.GITHUB_EVENT_NAME;
const payloadPath = process.env.GITHUB_EVENT_PATH;
// eslint-disable-next-line global-require, import/no-dynamic-require
const payload = require(path.resolve(payloadPath));
core.debug(`Receiving event ${JSON.stringify(event)}`);
return probot.receive({ name: event, payload, id: uuid.v4() }).catch(err => {
// setFailed logs the message and sets a failing exit code
core.setFailed(`Action failed with error: ${err.message}`);
throw err;
});
};