-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
57 lines (48 loc) · 1.48 KB
/
index.ts
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import {
compressBundleFolders,
getBundleScript,
getBundleSizes
} from './lib/helpers'
const exec = require('@actions/exec')
const core = require('@actions/core')
const github = require('@actions/github')
const run = async () => {
try {
const context = github.context
const pullRequest = context.payload.pull_request
const iosBundleScript = await getBundleScript(
'ios',
core.getInput('ios-entry-file'),
core.getInput('include-assets') === 'true',
core.getInput('include-source-maps') === 'true'
)
await exec.exec(iosBundleScript)
const androidBundleScript = await getBundleScript(
'android',
core.getInput('android-entry-file'),
core.getInput('include-assets') === 'true',
core.getInput('include-source-maps') === 'true'
)
await exec.exec(androidBundleScript)
compressBundleFolders()
const outputSizes = await getBundleSizes()
const token = core.getInput('token')
const octokit = github.getOctokit(token)
const description = `Android Bundle Size - ${outputSizes.android} | iOS Bundle Size - ${outputSizes.ios}`
const owner = pullRequest.head.repo.owner.login
const repo = pullRequest.head.repo.name
const sha = pullRequest.head.sha
const state = 'success'
await octokit.repos.createCommitStatus({
description,
owner,
repo,
sha,
state,
context: 'React Native Bundle Sizes'
})
} catch (error) {
core.setFailed(error.message)
}
}
run()