50
50
.map(dirent => dirent.name)
51
51
.filter(name => !name.startsWith('.'));
52
52
fs.writeFileSync('./cleaned/filelist.json', JSON.stringify(fileNames, null, 2));
53
+
54
+ - name : Create merch data
55
+
56
+ with :
57
+ script : |
58
+ const fs = require("fs");
59
+ const path = require("path");
60
+ const previewFormat = [".webp", ".png"];
61
+ const noDownloadFormat = [".json", ".webp"];
62
+ function capitalizeWords(str) {
63
+ return str.replace(/-/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
64
+ }
65
+ function getDirectoryStructure(dir) {
66
+ const result = {};
67
+ const items = fs.readdirSync(dir, { withFileTypes: true });
68
+ const files = items.filter((item) => !item.isDirectory());
69
+ const directories = items.filter((item) => item.isDirectory());
70
+ if (directories.length === 0 && files.length > 0) {
71
+ const preview = files.filter((file) => previewFormat.some((format) => file.name.endsWith(format)))
72
+ .map((file) => path.join(dir, file.name));
73
+ const download = files.filter((file) => !noDownloadFormat.some((format) => file.name.endsWith(format)))
74
+ .map((file) => path.join(dir, file.name));
75
+ return {
76
+ name: capitalizeWords(path.basename(dir)),
77
+ preview: preview,
78
+ download: download,
79
+ };
80
+ }
81
+ directories.forEach((directory) => {
82
+ result[directory.name] = getDirectoryStructure(
83
+ path.join(dir, directory.name)
84
+ );
85
+ });
86
+ return result;
87
+ }
88
+ const merchStructure = getDirectoryStructure("./merch");
89
+ const assetsStructure = getDirectoryStructure("./assets");
90
+ const stickersStructure = getDirectoryStructure("./stickers");
91
+ const combinedStructure = {
92
+ merch: merchStructure,
93
+ assets: assetsStructure,
94
+ stickers: stickersStructure,
95
+ };
96
+ fs.writeFileSync("./filelist.json", JSON.stringify(combinedStructure, null, 2));
97
+
53
98
- name : Upload to CDN
54
99
env :
55
100
AWS_ACCESS_KEY_ID : ${{ secrets.DEPLOY_AWS_ACCESS_KEY_ID }}
59
104
aws s3 cp stickers s3://cdn.rs.school/sloths/stickers --recursive --cache-control "public,max-age=300,immutable"
60
105
aws s3 cp cleaned s3://cdn.rs.school/sloths/cleaned --recursive --cache-control "public,max-age=300,immutable"
61
106
aws s3 cp assets s3://cdn.rs.school/assets --recursive --cache-control "public,max-age=300,immutable"
62
- aws s3 cp merch s3://cdn.rs.school/merch --recursive --cache-control "public,max-age=300,immutable"
107
+ aws s3 cp merch s3://cdn.rs.school/merch --recursive --cache-control "public,max-age=300,immutable"
0 commit comments