-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
235389b
commit d7e8a9d
Showing
2 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,13 +48,17 @@ jobs: | |
run: pnpm install --frozen-lockfile | ||
|
||
- name: Build step | ||
run: "cd client/web && pnpm build" # 📝 Update the build command(s) if necessary | ||
run: cd client/web && pnpm build | ||
env: | ||
SERVICE_URL: https://tailchat-nightly.moonrailgun.com | ||
|
||
- name: Copy Deno Entry | ||
run: cd client/web && cp ./scripts/deno-static-entry.ts ./dist/deno-static-entry.ts | ||
|
||
- name: Upload to Deno Deploy | ||
uses: denoland/deployctl@v1 | ||
with: | ||
project: "tailchat-nightly" | ||
entrypoint: https://deno.land/[email protected]/http/file_server.ts | ||
# entrypoint: https://deno.land/[email protected]/http/file_server.ts | ||
entrypoint: deno-static-entry.ts | ||
root: "./client/web/dist" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// @ts-nocheck | ||
import { serve } from 'https://deno.land/[email protected]/http/server.ts'; | ||
import { serveFile } from 'https://deno.land/[email protected]/http/file_server.ts'; | ||
import { fromFileUrl } from 'https://deno.land/[email protected]/path/mod.ts'; | ||
|
||
const clientRoot = new URL('./', import.meta.url); | ||
serve(async (req) => { | ||
const url = new URL(req.url); | ||
const localPath = new URL('./' + url.pathname, clientRoot); | ||
const filePath = fromFileUrl(localPath); | ||
|
||
const fileExists = await checkFileExists(filePath); | ||
if (fileExists) { | ||
return serveFile(req, filePath); | ||
} else { | ||
return await serveFile( | ||
req, | ||
fromFileUrl(new URL('./index.html', clientRoot)) | ||
); | ||
} | ||
}); | ||
|
||
async function checkFileExists(filePath: string): Promise<boolean> { | ||
try { | ||
await Deno.stat(filePath); | ||
return true; | ||
} catch (error) { | ||
if (error instanceof Deno.errors.NotFound) { | ||
return false; | ||
} else { | ||
throw error; | ||
} | ||
} | ||
} |