-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathentrypoint.js
executable file
·40 lines (33 loc) · 978 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
35
36
37
38
39
40
#!/usr/bin/env node
const {
GITHUB_TOKEN,
GITHUB_EVENT_NAME,
COMPRESS_ONLY
} = require('./dist/constants')
const githubEvent = require('./dist/github-event').default
const run = require('./dist/index.js').default
if (!GITHUB_TOKEN) {
console.log('::error:: You must enable the GITHUB_TOKEN secret')
process.exit(1)
}
const main = async () => {
if (!COMPRESS_ONLY) {
// 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(0)
}
}
await run()
}
main()