forked from calibreapp/image-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.js
executable file
·34 lines (27 loc) · 894 Bytes
/
entrypoint.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
28
29
30
31
32
33
34
#!/usr/bin/env node
const { GITHUB_TOKEN, GITHUB_EVENT_NAME } = require("./src/constants");
const githubEvent = require("./src/github-event");
const run = require("./src/index.js");
if (!GITHUB_TOKEN) {
console.log("::error:: You must enable the GITHUB_TOKEN secret");
process.exit(1);
}
const main = async () => {
// Bail out if the event that executed the action wasn’t a pull_request
if (GITHUB_EVENT_NAME !== "pull_request") {
console.log("::error:: This action only runs for pushes to PRs");
process.exit(78);
}
// Bail out if the pull_request event wasn't synchronize or opened
const event = await githubEvent();
if (event.action !== "synchronize" && event.action !== "opened") {
console.log(
"::error:: Check run has action",
event.action,
". Wants: synchronize or opened"
);
process.exit(78);
}
await run();
};
main();