-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
55 lines (51 loc) · 1.41 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
const core = require('@actions/core');
const { validateStatus } = require('@foo-software/lighthouse-check');
const formatInput = input => {
if (input === '') {
return undefined;
}
return input;
};
(async () => {
try {
const minAccessibilityScore = formatInput(
core.getInput('minAccessibilityScore')
);
const minBestPracticesScore = formatInput(
core.getInput('minBestPracticesScore')
);
const minPerformanceScore = formatInput(
core.getInput('minPerformanceScore')
);
const minProgressiveWebAppScore = formatInput(
core.getInput('minProgressiveWebAppScore')
);
const minSeoScore = formatInput(core.getInput('minSeoScore'));
const outputDirectory = formatInput(core.getInput('outputDirectory'));
let results = core.getInput('lighthouseCheckResults');
if (results) {
results = JSON.parse(results).data;
}
// if we need to fail when scores are too low...
if (
minAccessibilityScore ||
minBestPracticesScore ||
minPerformanceScore ||
minProgressiveWebAppScore ||
minSeoScore
) {
await validateStatus({
minAccessibilityScore,
minBestPracticesScore,
minPerformanceScore,
minProgressiveWebAppScore,
minSeoScore,
outputDirectory,
results,
verbose: true
});
}
} catch (error) {
core.setFailed(error.message);
}
})();