Skip to content

Commit b25f71b

Browse files
committed
2 parents 6726014 + c67aa89 commit b25f71b

4 files changed

Lines changed: 62 additions & 26 deletions

File tree

.github/workflows/pages.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: pages
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: '20'
27+
28+
- run: npm install
29+
30+
- run: node scripts/build.cjs
31+
32+
- uses: actions/upload-pages-artifact@v3
33+
with:
34+
path: dist
35+
36+
deploy:
37+
needs: build
38+
runs-on: ubuntu-latest
39+
environment:
40+
name: github-pages
41+
url: ${{ steps.deployment.outputs.page_url }}
42+
steps:
43+
- id: deployment
44+
uses: actions/deploy-pages@v4

CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs.ricecall.com

docs/CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs.ricecall.com

scripts/build.cjs

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
const fs = require("fs");
2-
const path = require("path");
3-
const crypto = require("crypto");
4-
const { execSync } = require("child_process");
1+
const fs = require('fs');
2+
const path = require('path');
3+
const crypto = require('crypto');
4+
const { execSync } = require('child_process');
55

6-
const ROOT = path.resolve(__dirname, "..");
7-
const DOCS = path.join(ROOT, "docs");
8-
const DIST = path.join(ROOT, "dist");
9-
const TMP = path.join(ROOT, "dist.tmp");
10-
const OLD = path.join(ROOT, "dist.old");
6+
const ROOT = path.resolve(__dirname, '..');
7+
const DOCS = path.join(ROOT, 'docs');
8+
const DIST = path.join(ROOT, 'dist');
9+
const TMP = path.join(ROOT, 'dist.tmp');
10+
const OLD = path.join(ROOT, 'dist.old');
1111

1212
function sha256(buf) {
13-
return crypto.createHash("sha256").update(buf).digest("hex");
13+
return crypto.createHash('sha256').update(buf).digest('hex');
1414
}
1515

1616
function gitVersion() {
1717
if (process.env.GITHUB_SHA) return process.env.GITHUB_SHA.slice(0, 12);
1818
try {
19-
return execSync("git rev-parse --short=12 HEAD", { cwd: ROOT })
20-
.toString()
21-
.trim();
19+
return execSync('git rev-parse --short=12 HEAD', { cwd: ROOT }).toString().trim();
2220
} catch {
23-
return "unknown";
21+
return 'unknown';
2422
}
2523
}
2624

@@ -45,7 +43,7 @@ function copyTree(srcDir, destDir) {
4543
const data = fs.readFileSync(srcPath);
4644
fs.writeFileSync(destPath, data);
4745
records.push({
48-
path: rel.split(path.sep).join("/"),
46+
path: rel.split(path.sep).join('/'),
4947
size: data.length,
5048
sha256: sha256(data),
5149
});
@@ -55,9 +53,7 @@ function copyTree(srcDir, destDir) {
5553

5654
function buildTree(dir) {
5755
const tree = {};
58-
const entries = fs
59-
.readdirSync(dir, { withFileTypes: true })
60-
.sort((a, b) => a.name.localeCompare(b.name));
56+
const entries = fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
6157
for (const e of entries) {
6258
if (e.isDirectory()) {
6359
tree[e.name] = buildTree(path.join(dir, e.name));
@@ -88,20 +84,14 @@ function main() {
8884
tree,
8985
};
9086

91-
fs.writeFileSync(
92-
path.join(TMP, "manifest.json"),
93-
JSON.stringify(manifest, null, 2),
94-
"utf8"
95-
);
87+
fs.writeFileSync(path.join(TMP, 'manifest.json'), JSON.stringify(manifest, null, 2), 'utf8');
9688

9789
rmrf(OLD);
9890
if (fs.existsSync(DIST)) fs.renameSync(DIST, OLD);
9991
fs.renameSync(TMP, DIST);
10092
rmrf(OLD);
10193

102-
console.log(
103-
`built dist/ — ${files.length} files, version ${manifest.version}`
104-
);
94+
console.log(`built dist/ — ${files.length} files, version ${manifest.version}`);
10595
}
10696

10797
main();

0 commit comments

Comments
 (0)