feat: Add GitHub Actions workflow to deploy 1000h entry website

This commit is contained in:
Lyric
2024-06-24 17:33:24 +09:00
parent 29ef9688a5
commit 71bd971810
3 changed files with 82 additions and 0 deletions

26
entry/index.js Normal file
View File

@@ -0,0 +1,26 @@
async function handleRequest(request, env) {
const { host, pathname } = new URL(request.url);
// for the root path, forward to Portal
// for other paths, forward to VTP
if (pathname === '/') {
return forwardToPortal(request, env);
} else {
return forwardToVtp(request, env);
}
}
async function renderInternalError(msg) {
return new Response(`Internal Error: ${msg}`, {
status: 500,
headers: { 'Content-Type': 'text/html' }
});
}
async function forwardToVtp(request, env) {
return await env.vtp.fetch(request)
}
async function forwardToPortal(request, env) {
return await env.portal.fetch(request)
}

14
entry/wrangler.toml Normal file
View File

@@ -0,0 +1,14 @@
name = "1000h-entry"
main = "index.js"
workers_dev = false
compatibility_date = "2023-03-23"
routes = ["next.1000h.org/*"]
services = [
{ binding = "vtp", service = "1000-hours-prod" },
{ binding = "portal", service = "1000h-portal" },
]
[vars]
HOST = "https://next.1000h.org"