Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:

jobs:
typecheck:
Expand Down Expand Up @@ -55,3 +56,51 @@ jobs:
- uses: oven-sh/setup-bun@v2
- run: npm ci
- run: npx libuild test --platform bun

# Deploy the website to GitHub Pages on push to master when website/ or docs/
# change — mirroring the crank/shovel flow (CI runs `npm run deploy`, which
# gh-pages-pushes dist/public, authenticated with GITHUB_TOKEN). Node, not bun:
# bun mis-handles unicode in the JSX template tags the site uses.
changes:
name: Detect Changes
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
outputs:
website: ${{ steps.check.outputs.website }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: check
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "website=true" >> "$GITHUB_OUTPUT"
elif git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -qE '^(website|docs)/'; then
echo "website=true" >> "$GITHUB_OUTPUT"
else
echo "website=false" >> "$GITHUB_OUTPUT"
fi

deploy:
name: Deploy Website
needs: [typecheck, build, test-node, changes]
if: github.ref == 'refs/heads/master' && needs.changes.outputs.website == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install
working-directory: website
- name: Deploy website
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
npm run deploy
working-directory: website
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110 changes: 0 additions & 110 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
"private": true,
"type": "module",
"scripts": {
"develop": "shovel develop src/server.ts --platform node --port 1338",
"clean": "rm -rf dist",
"static": "npm run clean && MODE=production shovel build src/server.ts --platform node --lifecycle",
"pagefind": "pagefind --site dist/public",
"develop": "shovel develop src/server.ts --port 1338 --platform node",
"static": "MODE=production shovel build src/server.ts --platform node --lifecycle",
"predeploy": "npm run static",
"deploy": "gh-pages -d dist/public --nojekyll --cname repeater.js.org"
},
Expand All @@ -23,7 +21,6 @@
"gh-pages": "^6.3.0",
"marked": "^4.3.0",
"normalize.css": "^8.0.1",
"pagefind": "^1.4.0",
"prismjs": "^1.30.0"
},
"devDependencies": {
Expand Down
7 changes: 1 addition & 6 deletions website/shovel.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
"export": "NodeFSDirectory",
"path": "../docs"
},
"public": {},
"pagefind": {
"module": "@b9g/filesystem/node-fs",
"export": "NodeFSDirectory",
"path": "./dist/public/pagefind"
}
"public": {}
},
"logging": {
"loggers": [{ "category": "shovel", "level": "info" }]
Expand Down
27 changes: 0 additions & 27 deletions website/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,6 @@ router.route("/docs/:slug/").get(async (request, context) => {
return renderView(GuideView, url.pathname, context.params);
});

// Serve pagefind search assets (generated by the static build).
router.route("/pagefind/:path*").get(async (request, context) => {
try {
const pagefindDir = await self.directories.open("pagefind");
const parts = (context.params.path || "").split("/").filter(Boolean);
let dir = pagefindDir;
for (let i = 0; i < parts.length - 1; i++) {
dir = await dir.getDirectoryHandle(parts[i]);
}
const fileName = parts[parts.length - 1] || "";
const handle = await dir.getFileHandle(fileName);
const file = await handle.getFile();
const ext = fileName.slice(fileName.lastIndexOf(".")).toLowerCase();
const contentType =
ext === ".js"
? "application/javascript"
: ext === ".css"
? "text/css"
: "application/octet-stream";
return new Response(await file.arrayBuffer(), {
headers: { "Content-Type": contentType },
});
} catch {
return new Response("Not Found (run the static build first)", { status: 404 });
}
});

router.route("*").all(async (request) => {
const url = new URL(request.url);
const html = await renderer.render(
Expand Down
Loading