-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.mjs
More file actions
27 lines (26 loc) · 1.02 KB
/
deploy.mjs
File metadata and controls
27 lines (26 loc) · 1.02 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
/* eslint-disable no-console */
import { execa } from "execa";
import * as fs from "fs";
(async () => {
try {
await execa("git", ["checkout", "--orphan", "gh-pages"]);
// eslint-disable-next-line no-console
console.log("Building started...");
await execa("npm", ["run", "build"]);
// await execa("yarn", ["build"]);
// Understand if it's dist or build folder
const folderName = fs.existsSync("dist") ? "dist" : "build";
await execa("git", ["--work-tree", folderName, "add", "--all"]);
await execa("git", ["--work-tree", folderName, "commit", "-m", "gh-pages"]);
console.log("Pushing to gh-pages...");
await execa("git", ["push", "origin", "HEAD:gh-pages", "--force"]);
await execa("rm", ["-r", folderName]);
await execa("git", ["checkout", "-f", "main"]);
await execa("git", ["branch", "-D", "gh-pages"]);
console.log("Successfully deployed, check your settings");
} catch (e) {
// eslint-disable-next-line no-console
console.log(e.message);
process.exit(1);
}
})();