-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (28 loc) · 939 Bytes
/
index.js
File metadata and controls
37 lines (28 loc) · 939 Bytes
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
const core = require('@actions/core');
try {
const data = core.getInput('data').toString();
const matcher = core.getInput('matcher');
console.log(`Executing with: ${data}`);
console.log(`Comparing to matcher(s): ${matcher}`);
let splitMatches = matcher.split(',');
let useMatch = core.getInput('use-match');
let filteredOutput = [];
//Convert data into JS friendly
let cleanJSONString = data.replace(/\\/g,'');
let cleanDataArray = JSON.parse(cleanJSONString);
let addToArray = (item) => {
if (!filteredOutput.includes(item)) filteredOutput.push(item);
}
cleanDataArray.forEach(str => {
splitMatches.forEach(match => {
if (str.includes(match)) {
if (useMatch) addToArray(match);
else addToArray(str);
}
});
});
console.log(`Output: ${filteredOutput}`);
core.setOutput("array", filteredOutput);
} catch (error) {
core.setFailed(error.message);
}