forked from DevExpress/github-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
40 lines (33 loc) · 1.03 KB
/
main.ts
File metadata and controls
40 lines (33 loc) · 1.03 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
import * as fs from 'fs';
import * as core from '@actions/core';
import {
inputs,
getChangedFiles,
ensureDir,
setOutputs,
testPath,
} from 'common';
async function run(): Promise<void> {
try {
const pathPatterns = core.getInput(inputs.PATHS).split(';');
const token = core.getInput(inputs.GH_TOKEN, { required: true });
console.log('patterns: ' + JSON.stringify(pathPatterns, undefined, 2));
const changedFiles = await getChangedFiles(token);
const filteredFiles = pathPatterns.length > 0
? changedFiles.filter(({ path }) => testPath(path, pathPatterns))
: changedFiles;
setOutputs({
json: JSON.stringify({
files: filteredFiles,
count: filteredFiles.length,
}),
files: filteredFiles.map(e => e.path),
count: filteredFiles.length,
});
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message)
}
}
}
run()