forked from foo-software/lighthouse-check-action
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
59 lines (52 loc) · 2.16 KB
/
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
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
58
59
const core = require('@actions/core');
const get = require('lodash.get');
const github = require('@actions/github');
const { lighthouseCheck } = require('@foo-software/lighthouse-check');
const formatInput = input => {
if (input === 'true') {
return true;
}
if (input === 'false') {
return false;
}
if (input === '') {
return undefined;
}
return input;
};
(async () => {
try {
const urls = formatInput(core.getInput('urls'));
const results = await lighthouseCheck({
author: formatInput(core.getInput('author')),
apiToken: formatInput(core.getInput('apiToken')),
awsAccessKeyId: formatInput(core.getInput('awsAccessKeyId')),
awsBucket: formatInput(core.getInput('awsBucket')),
awsRegion: formatInput(core.getInput('awsRegion')),
awsSecretAccessKey: formatInput(core.getInput('awsSecretAccessKey')),
branch: formatInput(core.getInput('branch')),
configFile: formatInput(core.getInput('configFile')),
emulatedFormFactor: formatInput(core.getInput('emulatedFormFactor')),
locale: formatInput(core.getInput('locale')),
help: formatInput(core.getInput('help')),
outputDirectory: formatInput(core.getInput('outputDirectory')),
pr: formatInput(core.getInput('pr')),
prCommentAccessToken: formatInput(core.getInput('accessToken')),
prCommentUrl: get(github, 'context.payload.pull_request.comments_url'),
sha: formatInput(core.getInput('sha')),
slackWebhookUrl: formatInput(core.getInput('slackWebhookUrl')),
tag: formatInput(core.getInput('tag')),
timeout: formatInput(core.getInput('timeout')),
throttling: formatInput(core.getInput('throttling')),
throttlingMethod: formatInput(core.getInput('throttlingMethod')),
urls: !urls ? undefined : urls.split(','),
verbose: formatInput(core.getInput('verbose')),
wait: formatInput(core.getInput('wait'))
});
// yikesers - only strings :(
// https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions#steps-context
core.setOutput('lighthouseCheckResults', JSON.stringify(results));
} catch (error) {
core.setFailed(error.message);
}
})();