-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-deploy-matrix.js
42 lines (33 loc) · 1.07 KB
/
generate-deploy-matrix.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
import { readFile } from "fs/promises";
import process from "process";
let files = JSON.parse(await readFile(`${process.env.HOME}/files.json`));
let directories = new Set();
for (let file of files) {
let directory = file.split("/")[0];
directories.add(directory);
}
let configs = [];
for (let directory of directories) {
try {
let config = JSON.parse(await readFile(`./${directory}/config.json`));
configs.push({
...config,
directory: directory
});
}
catch (e) {
}
}
if (configs.length != 0) console.log(JSON.stringify({
project: configs.map(config => {
let fullUploadPath = config.directory.split("/");
if (config.upload) fullUploadPath.push(...config.upload.split("/"));
return {
site: config.site,
build: config.build ?? null,
"build-working-directory": config.directory,
upload: fullUploadPath[fullUploadPath.length - 1],
"upload-working-directory": fullUploadPath.length == 1 ? "" : fullUploadPath[0]
};
})
}));