-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.js
62 lines (57 loc) · 2.16 KB
/
deploy.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
58
59
60
61
62
import fs from "fs-extra";
import path from "path";
import ghpages from "gh-pages";
const ghToken = process.env.GITHUB_TOKEN,
gitUser = ghToken
? {
name: "github-actions-bot",
email: "[email protected]",
}
: {
name: "Matteo Bruni",
email: "[email protected]",
};
(async () => {
if (!(await fs.pathExists("./dist"))) {
await fs.mkdir("./dist");
}
await fs.copy("./audio", "./dist/audio");
await fs.copy("./configs", "./dist/configs");
await fs.copy("./css", "./dist/css");
await fs.copy("./fonts", "./dist/fonts");
await fs.copy("./images", "./dist/images");
await fs.copy("./js", "./dist/js");
await fs.copy("./samples", "./dist/samples");
await fs.copy("./schema", "./dist/schema");
await fs.copy("./videos", "./dist/videos");
await fs.copyFile("./.nojekyll", "./dist/.nojekyll");
await fs.copyFile("./404.html", "./dist/404.html");
await fs.copyFile("./ads.txt", "./dist/ads.txt");
await fs.copyFile("./CNAME", "./dist/CNAME");
await fs.copyFile("./favicon.ico", "./dist/favicon.ico");
await fs.copyFile("./index.html", "./dist/index.html");
await fs.copyFile("./privacy.html", "./dist/privacy.html");
await fs.copyFile("./sitemap.xml", "./dist/sitemap.xml");
await fs.copyFile("./tsParticles-64.png", "./dist/tsParticles-64.png");
await fs.copyFile("./video.html", "./dist/video.html");
ghpages.publish(
path.join(".", "dist"),
{
repo: ghToken
? `https://git:${ghToken}@github.com/tsparticles/website.git`
: `https://github.com/tsparticles/website.git`,
dotfiles: true,
history: false,
message: "build: gh pages updated",
user: gitUser,
},
function (publishErr) {
if (!publishErr) {
console.log("Website published successfully");
} else {
console.log(`Error publishing website: ${publishErr}`);
}
fs.rmSync(path.join(".", "dist"), { recursive: true });
},
);
})();