-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
49 lines (39 loc) · 1.34 KB
/
Copy pathindex.ts
File metadata and controls
49 lines (39 loc) · 1.34 KB
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
import {
getInput,
getMultilineInput,
setFailed,
info,
setOutput,
} from '@actions/core';
import { context, getOctokit } from '@actions/github';
import { GithubInput } from './src/types';
import { ParserService } from './src/parser.service';
import { FilterService } from './src/filter.service';
const input: GithubInput = {
token: getInput('token', { required: true }),
folder: getInput('folder', { required: false }),
exclude: getMultilineInput('exclude', { required: false }),
include: getMultilineInput('include', { required: false }),
context: context,
};
(async () => {
const github = getOctokit(input.token);
const parser = new ParserService(input.context, github);
const parsed = await parser.diff();
if (parsed.completed === false) {
return setFailed(parsed.error);
}
const filter = new FilterService({
root: input.folder,
include: input.include,
exclude: input.exclude,
});
const matrix = filter.filter(parsed.files);
console.log('Will set output matrix:', JSON.stringify({ services: matrix }));
if (!matrix) {
info(
`Unable to construct a valid services matrix. The diff may only include files outside the expected folder (${input.folder}), or there might be no changes at all. Returning an empty matrix.`,
);
}
setOutput('matrix', JSON.stringify({ services: matrix }));
})();