Add GitHub Pages deployment workflow for the demo site

Builds core -> widget -> demo and publishes packages/demo/dist via
actions/upload-pages-artifact + deploy-pages. Also makes the manifest and
service worker's precache list path-relative (instead of root-absolute)
so the same build works whether it's served from a domain root or a
GitHub Pages project-site subpath like /bitlogin/.

Repo still needs Settings -> Pages -> Source set to "GitHub Actions" once
if it has never been enabled before.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GWJbXXhvTx9wo59jSz57J6
This commit is contained in:
Claude committed 2026-07-21 03:53:52 +00:00
1 parent 0991a5c68f
commit 21dd474781
4 files changed
+88 -14

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
name: Deploy demo to GitHub Pages
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- run: npm run build -w @bitlogin/core
- run: npm run build -w @bitlogin/widget
- run: npm run build -w @bitlogin/demo
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: packages/demo/dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
+23
View File
@@ -22,6 +22,14 @@
"resolved": "packages/core",
"link": true
},
"node_modules/@bitlogin/demo": {
"resolved": "packages/demo",
"link": true
},
"node_modules/@bitlogin/widget": {
"resolved": "packages/widget",
"link": true
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.25.12",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz",
@@ -1757,6 +1765,21 @@
"vitest": "^3.0.5",
"ws": "^8.21.1"
}
},
"packages/demo": {
"name": "@bitlogin/demo",
"version": "0.1.0"
},
"packages/widget": {
"name": "@bitlogin/widget",
"version": "0.1.0",
"dependencies": {
"@bitlogin/core": "*"
},
"devDependencies": {
"typescript": "^5.7.3",
"vite": "^6.1.0"
}
}
}
}
+3 -3
View File
@@ -2,12 +2,12 @@
"name": "BitLogin",
"short_name": "BitLogin",
"description": "A portable Nostr identity behind a familiar login name and password.",
"start_url": "/account.html",
"scope": "/",
"start_url": "./account.html",
"scope": "./",
"display": "standalone",
"background_color": "#0b0b12",
"theme_color": "#8b5cf6",
"icons": [
{ "src": "/assets/icon.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "any" }
{ "src": "./assets/icon.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "any" }
]
}
+15 -11
View File
@@ -6,17 +6,21 @@
* not on that list passes straight through to the network untouched.
*/
const CACHE_NAME = "bitlogin-demo-v1";
const PRECACHE_URLS = [
"/",
"/index.html",
"/docs.html",
"/account.html",
"/assets/site.css",
"/assets/icon.svg",
"/manifest.webmanifest",
"/vendor/bitlogin/bitlogin.js",
"/vendor/bitlogin/cryptoWorker.js"
// Relative to this script's own location, so the same file works whether the
// site is served from a domain root or a subpath (e.g. a GitHub Pages project
// site at /bitlogin/).
const PRECACHE_PATHS = [
"./",
"./index.html",
"./docs.html",
"./account.html",
"./assets/site.css",
"./assets/icon.svg",
"./manifest.webmanifest",
"./vendor/bitlogin/bitlogin.js",
"./vendor/bitlogin/cryptoWorker.js"
];
const PRECACHE_URLS = PRECACHE_PATHS.map((p) => new URL(p, self.location.href).toString());
self.addEventListener("install", (event) => {
event.waitUntil(
@@ -36,7 +40,7 @@ self.addEventListener("activate", (event) => {
self.addEventListener("fetch", (event) => {
const url = new URL(event.request.url);
if (event.request.method !== "GET" || url.origin !== self.location.origin) return;
if (!PRECACHE_URLS.includes(url.pathname)) return;
if (!PRECACHE_URLS.includes(url.toString())) return;
event.respondWith(
caches.match(event.request).then((cached) => {