This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
57 lines (48 loc) · 1.94 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
const core = require('@actions/core');
const github = require('@actions/github');
const exec = require('@actions/exec');
const filematcher = require('./filematcher');
async function run() {
const token = core.getInput('githubToken');
const octokit = github.getOctokit(token);
let runEverything = false;
let filenames = [];
if (github.context.payload.pull_request.changed_files > 3000) {
console.log('More than 3000 files updated, running everything!');
runEverything = true;
} else {
do {
const { data: files } = await octokit.rest.pulls.listFiles({
owner: github.context.payload.repository.owner.login,
repo: github.context.payload.repository.name,
pull_number: github.context.payload.pull_request.number,
per_page: 100,
});
const paginatedFilenames = files.map((file) => file.filename);
filenames = [...filenames, ...paginatedFilenames];
} while (
filenames.length < github.context.payload.pull_request.changed_files
);
}
if (filenames.find((file) => file.startsWith('.github/workflows/'))) {
console.log('Workflows updated, running everything!');
runEverything = true;
}
if (runEverything) {
core.setOutput('run_python', 'true');
core.setOutput('run_admin', 'true');
core.setOutput('run_importer', 'true');
core.setOutput('run_webclient', 'true');
return;
}
const run = filematcher(filenames);
console.log('run_python =', run.python);
console.log('run_admin =', run.admin);
console.log('run_importer =', run.importer);
console.log('run_webclient =', run.webclient);
core.setOutput('run_python', `${run.python}`);
core.setOutput('run_admin', `${run.admin}`);
core.setOutput('run_importer', `${run.importer}`);
core.setOutput('run_webclient', `${run.webclient}`);
}
run();