Skip to content

Commit 160ff4d

Browse files
authored
fix: ci deploy & 404 github pages (#23)
1 parent cb00fe8 commit 160ff4d

3 files changed

Lines changed: 43 additions & 3 deletions

File tree

.github/workflows/deploy-mildstack-dev.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Setup Node
3333
uses: actions/setup-node@v4
3434
with:
35-
node-version: '20'
35+
node-version: '22'
3636
cache: 'npm'
3737
cache-dependency-path: './apps/web/www/package-lock.json'
3838

@@ -43,12 +43,12 @@ jobs:
4343
run: npm run build
4444

4545
- name: Add Custom Domain CNAME
46-
run: echo "mildstack.dev" > dist/CNAME
46+
run: echo "mildstack.dev" > build/client/CNAME
4747

4848
- name: Upload artifact
4949
uses: actions/upload-pages-artifact@v3
5050
with:
51-
path: ./apps/web/www/dist
51+
path: ./apps/web/www/build/client
5252

5353
deploy:
5454
name: Deploy to GitHub Pages

apps/web/www/app/root.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ export function Layout({ children }: { children: React.ReactNode }) {
4747
<meta property="twitter:title" content="MildStack - Open Source LocalStack Alternative" />
4848
<meta property="twitter:description" content="Lightweight, local-first AWS emulator for developers. Fast, simple, and memory-efficient local cloud API." />
4949
<meta property="twitter:image" content="/og-image.png" />
50+
{/* spa-github-pages: restore real URL from 404.html redirect */}
51+
<script
52+
dangerouslySetInnerHTML={{
53+
__html: `(function(l){if(l.search[1]=='/'){var decoded=l.search.slice(1).split('&').map(function(s){return s.replace(/~and~/g,'&')}).join('?');window.history.replaceState(null,null,l.pathname.slice(0,-1)+decoded+l.hash)}}(window.location))`,
54+
}}
55+
/>
5056
<Meta />
5157
<Links />
5258
</head>

apps/web/www/public/404.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>MildStack</title>
6+
<script type="text/javascript">
7+
// Single Page Apps for GitHub Pages
8+
// MIT License
9+
// https://github.com/rafgraph/spa-github-pages
10+
// This script takes the current url and converts the path and query
11+
// string into just a query string, and then redirects the browser
12+
// to the new url with only a query string and hash fragment,
13+
// e.g. https://www.foo.tld/one/two?a=b&c=d#qwe, becomes
14+
// https://www.foo.tld/?/one/two&a=b~and~c=d#qwe
15+
// Note: this 404.html file must be at least 512 bytes for it to work
16+
// with Internet Explorer (it is currently > 512 bytes)
17+
18+
// Using a custom domain (mildstack.dev), so pathSegmentsToKeep = 0.
19+
// If deploying to username.github.io/repo-name, set to 1.
20+
var pathSegmentsToKeep = 0;
21+
22+
var l = window.location;
23+
l.replace(
24+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
25+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
26+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
27+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
28+
l.hash
29+
);
30+
</script>
31+
</head>
32+
<body>
33+
</body>
34+
</html>

0 commit comments

Comments
 (0)