-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.mjs
29 lines (26 loc) · 905 Bytes
/
main.mjs
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
28
29
import child_process from 'child_process';
import fs from 'fs';
import path from 'path';
import url from 'url';
const event = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH));
if (process.env.GITHUB_EVENT_NAME !== 'pull_request') {
console.log('skip: not a pull request');
process.exit(0);
} else if (event.sender.type !== 'User') {
console.log('skip: triggered by a bot');
process.exit(0);
}
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
const args = [
'-uS', path.resolve(__dirname, 'bin/main'),
'--msg', process.env.INPUT_MSG,
'--pr', event.number.toString(10),
'--run-id', process.env.GITHUB_RUN_ID,
'--runtime-token', process.env.ACTIONS_RUNTIME_TOKEN,
'--runtime-url', process.env.ACTIONS_RUNTIME_URL,
];
try {
child_process.execFileSync('python3', args, {stdio: 'inherit'});
} catch (e) {
process.exit(e.status);
}