Skip to content

Commit 6c7e997

Browse files
brian033claude
andcommitted
deploy: add GitHub Pages workflow and SPA routing workaround
- GitHub Actions workflow to build and deploy on push to main - 404.html redirect for SPA client-side routing on GitHub Pages - Harden .gitignore with .env*, IDE dirs, and TSV data files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 658c035 commit 6c7e997

4 files changed

Lines changed: 82 additions & 0 deletions

File tree

.github/workflows/deploy.yml

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

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ coverage/
44
*.tsbuildinfo
55
.DS_Store
66
.worktrees/
7+
.env*
8+
.vscode/
9+
.idea/
10+
*.tsv

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
content="c4Lab builds computational solutions for biological problems across genomics, multi-omics, and precision medicine."
99
/>
1010
<title>c4Lab</title>
11+
<!-- SPA redirect handler for GitHub Pages 404.html workaround -->
12+
<script>
13+
(function(l) {
14+
if (l.search[1] === '/') {
15+
var decoded = l.search.slice(1).split('&').map(function(s) {
16+
return s.replace(/~and~/g, '&');
17+
}).join('?');
18+
window.history.replaceState(null, null,
19+
l.pathname.slice(0, -1) + decoded + l.hash
20+
);
21+
}
22+
}(window.location));
23+
</script>
1124
<script type="module" src="/src/main.tsx"></script>
1225
</head>
1326
<body class="bg-paper text-ink antialiased">

public/404.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>c4Lab</title>
6+
<script>
7+
// SPA redirect for GitHub Pages
8+
// Converts the path into a query string so index.html can restore it
9+
var pathSegmentsToKeep = 0;
10+
var l = window.location;
11+
l.replace(
12+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
13+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
14+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
15+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
16+
l.hash
17+
);
18+
</script>
19+
</head>
20+
<body>
21+
</body>
22+
</html>

0 commit comments

Comments
 (0)