-
Notifications
You must be signed in to change notification settings - Fork 11
Deploy to void #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Deploy to void #13
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
c92bbbf
Migrate blog to Void (Vite + Cloudflare Workers + Vue 3)
fengmk2 1d90374
Replace GitHub ribbon with Deploy on V___ ribbon
fengmk2 d23061f
Fix deploy: move legacy files, fix SSR CSS and Disqus scripts
fengmk2 dbced21
Fix ppt deck.js paths to use relative URLs
fengmk2 9f90894
Return 404 for unknown paths and add sitemap generator
fengmk2 c61bdb8
Switch void packages to @void-sdk GitHub Packages aliases
fengmk2 2f75ebf
update deps
fengmk2 04c1a30
Add PR staging deploy workflow, switch deploy to pnpm
fengmk2 86eaa80
ignore .void
fengmk2 be23803
Switch CI/deploy workflows to voidzero-dev/setup-vp
fengmk2 dfcaac1
Migrate project to Vite+ (vp)
fengmk2 d5fa8c4
fmt
fengmk2 f40f670
Pin setup-vp to voidzero-dev/setup-vp#52
fengmk2 95b37e1
Bump setup-vp PR #52 pin to latest head
fengmk2 29e1023
Refactor setup-vp usage to PR #54 latest behavior
fengmk2 9609c50
Bump setup-vp PR #54 pin to latest head (af4ffd9 -> 42d342a)
fengmk2 fa7eae8
Pin setup-vp to the merged commit of PR #54
fengmk2 aa21c2b
Use voidzero-dev/setup-vp@v1 floating tag
fengmk2 d676ce4
Fixup
fengmk2 a7b5b11
Serve a real 404 page for unknown URLs
fengmk2 81425b2
Give every page a <title>
fengmk2 9164264
Log user-agent and client IP on 404 hits
fengmk2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,8 @@ | ||
| { | ||
| "mcpServers": { | ||
| "void": { | ||
| "command": "npx", | ||
| "args": ["void", "mcp"] | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 @@ | ||
| ../../../../voidzero-dev/void/packages/void/skills/migrate-vite-cloudflare-to-void |
This file contains hidden or 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 @@ | ||
| ../../../../voidzero-dev/void/packages/void/skills/void |
This file contains hidden or 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,67 @@ | ||
| name: CI | ||
| on: | ||
| push: | ||
| branches: [master] | ||
| pull_request: | ||
| branches: [master] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: voidzero-dev/setup-vp@v1 | ||
| with: | ||
| cache: true | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} | ||
| - run: vp check | ||
| - run: vp run build | ||
|
|
||
| staging-deploy: | ||
| needs: test | ||
| if: github.event_name == 'pull_request' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: voidzero-dev/setup-vp@v1 | ||
| with: | ||
| cache: true | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} | ||
| - run: vp run sitemap | ||
| - run: vpx void deploy | ||
| env: | ||
| VOID_TOKEN: ${{ secrets.VOID_TOKEN }} | ||
| VOID_PROJECT: fengmk2-staging | ||
| - name: Comment on PR | ||
| uses: actions/github-script@v9 | ||
| with: | ||
| script: | | ||
| const marker = '<!-- staging-deploy -->'; | ||
| const body = `${marker}\n✅ Staging deployment successful!\n\nPreview: https://fengmk2-staging.void.app/\nCommit: ${context.sha}`; | ||
| const comments = await github.paginate(github.rest.issues.listComments, { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| }); | ||
| const existing = comments.find(c => c.body.includes(marker)); | ||
| if (existing) { | ||
| await github.rest.issues.updateComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| comment_id: existing.id, | ||
| body, | ||
| }); | ||
| } else { | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| body, | ||
| }); | ||
| } |
This file contains hidden or 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,20 @@ | ||
| name: Deploy | ||
| on: | ||
| push: | ||
| branches: [master] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: voidzero-dev/setup-vp@v1 | ||
| with: | ||
| cache: true | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} | ||
| - run: vp run sitemap | ||
| - run: vpx void deploy | ||
| env: | ||
| VOID_TOKEN: ${{ secrets.VOID_TOKEN }} |
This file contains hidden or 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
This file contains hidden or 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 @@ | ||
| 24.14.0 | ||
This file contains hidden or 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 @@ | ||
| @void-sdk:registry=https://npm.pkg.github.com |
This file contains hidden or 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 @@ | ||
| vp staged |
This file contains hidden or 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,73 @@ | ||
| import app, { scheduled, __voidCollectPrerenderPaths, __voidHandleWebSocket, __withRawEnv } from 'virtual:void-routes'; | ||
| import { withRuntimeEnv } from "/Users/fengmk2/git/github.com/fengmk2/fengmk2.github.com/node_modules/.pnpm/@void-sdk+void@0.5.0_@void-sdk+md@0.5.0_@void-sdk+react@0.5.0_@void-sdk+solid@0.5.0_@vo_65db7940de9b53d51259765009dc4b8c/node_modules/@void-sdk/void/dist/runtime/env.mjs"; | ||
|
|
||
| function __filterInternalBindings(env) { | ||
| return new Proxy(env, { | ||
| get(target, prop, receiver) { | ||
| if (typeof prop === "string" && (prop.startsWith("__VOID_") || prop.startsWith("__PROJECT_"))) return undefined; | ||
| return Reflect.get(target, prop, receiver); | ||
| }, | ||
| has(target, prop) { | ||
| if (typeof prop === "string" && (prop.startsWith("__VOID_") || prop.startsWith("__PROJECT_"))) return false; | ||
| return Reflect.has(target, prop); | ||
| }, | ||
| ownKeys(target) { | ||
| return Reflect.ownKeys(target).filter( | ||
| (key) => typeof key !== "string" || (!key.startsWith("__VOID_") && !key.startsWith("__PROJECT_")) | ||
| ); | ||
| }, | ||
| getOwnPropertyDescriptor(target, prop) { | ||
| if (typeof prop === "string" && (prop.startsWith("__VOID_") || prop.startsWith("__PROJECT_"))) return undefined; | ||
| return Reflect.getOwnPropertyDescriptor(target, prop); | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| async function serveWithAssets(request, env, response) { | ||
| if (response.status !== 404 || !env.ASSETS || (request.method !== "GET" && request.method !== "HEAD")) return response; | ||
| const asset = await env.ASSETS.fetch(new Request(request.url, { method: request.method, headers: request.headers })); | ||
| if (asset.status === 404) return response; | ||
| const res = new Response(asset.body, asset); | ||
| if (new URL(request.url).pathname.startsWith("/assets/")) { | ||
| res.headers.set("Cache-Control", "public, max-age=31536000, immutable"); | ||
| } else { | ||
| res.headers.set("Cache-Control", "public, s-maxage=60, max-age=0, must-revalidate"); | ||
| } | ||
| return res; | ||
| } | ||
|
|
||
| async function __handleInternal(request, env, ctx) { | ||
| const url = new URL(request.url); | ||
| // Readiness probe — platform polls this to confirm the worker is live after WfP upload. | ||
| // Handled here (before app.fetch) so user middleware cannot block it. | ||
| if (request.method === "GET" && url.pathname === "/__void/ready") { | ||
| return Response.json({ ready: true }); | ||
| } | ||
| if (request.method !== "POST" || url.pathname !== "/__void/prerender-paths") return null; | ||
| const __expected = env.__VOID_PROXY_TOKEN; | ||
| if (__expected) { | ||
| const __token = request.headers.get("x-void-internal"); | ||
| if (!__token || __token !== __expected) { | ||
| return Response.json({ error: "unauthorized" }, { status: 401 }); | ||
| } | ||
| } | ||
| const paths = await __voidCollectPrerenderPaths(request, env, ctx); | ||
| return Response.json({ paths }); | ||
| } | ||
| async function handleScheduled(controller, env, ctx) { | ||
| const userEnv = __filterInternalBindings(env); | ||
| return withRuntimeEnv(env, () => scheduled(controller, userEnv, ctx)); | ||
| } | ||
|
|
||
| export default { fetch: async (request, env, ctx) => { | ||
| const ws = await __voidHandleWebSocket(request, env); | ||
| if (ws) return ws; | ||
| return __withRawEnv(env, () => { | ||
| const userEnv = __filterInternalBindings(env); | ||
| return withRuntimeEnv(env, async () => { | ||
| const internal = await __handleInternal(request, env, ctx); | ||
| if (internal) return internal; | ||
| return serveWithAssets(request, env, await app.fetch(request, userEnv, ctx)); | ||
| }); | ||
| }); | ||
| }, scheduled: handleScheduled }; |
This file contains hidden or 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,11 @@ | ||
| // Auto-generated by @void/md — do not edit | ||
|
|
||
| export interface VoidMdPage { | ||
| path: string; | ||
| title: string; | ||
| frontmatter: Record<string, unknown>; | ||
| headings: { depth: number; slug: string; text: string }[]; | ||
| } | ||
|
|
||
| declare const pages: VoidMdPage[]; | ||
| export default pages; |
This file contains hidden or 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,5 @@ | ||
| // Auto-generated by void — do not edit | ||
| export interface QueueMap { | ||
| } | ||
|
|
||
| export declare const queues: QueueMap; |
This file contains hidden or 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,97 @@ | ||
| // Auto-generated by void — do not edit | ||
| export {} | ||
| interface StandardSchemaV1<Input = unknown, Output = Input> { | ||
| readonly "~standard": { | ||
| readonly version: 1; | ||
| readonly vendor: string; | ||
| readonly validate: (value: unknown) => unknown; | ||
| readonly types?: { readonly input: Input; readonly output: Output } | undefined; | ||
| }; | ||
| } | ||
| declare namespace StandardSchemaV1 { | ||
| type InferInput<Schema extends StandardSchemaV1> = NonNullable< | ||
| Schema["~standard"]["types"] | ||
| >["input"]; | ||
| type InferOutput<Schema extends StandardSchemaV1> = NonNullable< | ||
| Schema["~standard"]["types"] | ||
| >["output"]; | ||
| } | ||
|
|
||
| type Serialize<T> = | ||
| T extends Response ? never : | ||
| T extends Date ? string : | ||
| T extends bigint ? never : | ||
| T extends Function ? never : | ||
| T extends undefined ? never : | ||
| T extends Array<infer U> ? Array<Serialize<U>> : | ||
| T extends object ? { [K in keyof T as T[K] extends Function ? never : K]: Serialize<T[K]> } : | ||
| T; | ||
|
|
||
| type ExtractInput<V> = { | ||
| [K in keyof V as V[K] extends StandardSchemaV1 ? K : never]: | ||
| V[K] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<V[K]> : never; | ||
| }; | ||
|
|
||
| type ExtractOutput<S> = | ||
| S extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<S> : never; | ||
|
|
||
| type RouteParams<P extends readonly string[]> = | ||
| P extends readonly [] ? Record<string, never> : { [K in P[number]]: string }; | ||
|
|
||
| declare module "void/routes" { | ||
| export interface RouteMap {} | ||
| export interface WebSocketRouteMap {} | ||
| export interface PageActionMap {} | ||
|
|
||
| export type ParseActionUrl<U extends string> = U extends `${infer Base}?${infer Action}` ? { | ||
| base: Base; | ||
| action: Action; | ||
| } : { | ||
| base: U; | ||
| action: never; | ||
| }; | ||
|
|
||
| export type ResolveActionBody<U extends string> = | ||
| ParseActionUrl<U>["base"] extends keyof PageActionMap | ||
| ? ParseActionUrl<U>["action"] extends never | ||
| ? PageActionMap[ParseActionUrl<U>["base"]] extends { body: infer B } | ||
| ? B | ||
| : Record<string, unknown> | ||
| : PageActionMap[ParseActionUrl<U>["base"]] extends { actions: infer A } | ||
| ? ParseActionUrl<U>["action"] extends keyof A | ||
| ? A[ParseActionUrl<U>["action"]] extends { body: infer B } | ||
| ? B | ||
| : Record<string, unknown> | ||
| : never | ||
| : never | ||
| : Record<string, unknown>; | ||
|
|
||
| export type ResolveActionParams<U extends string> = | ||
| ParseActionUrl<U>["base"] extends keyof PageActionMap | ||
| ? PageActionMap[ParseActionUrl<U>["base"]] extends { params: infer P } | ||
| ? P | ||
| : never | ||
| : never; | ||
|
|
||
| export type HasActionParams<U extends string> = | ||
| ResolveActionParams<U> extends Record<string, string> ? true : false; | ||
|
|
||
| export type ActionFormOptions<U extends string> = | ||
| HasActionParams<U> extends true ? { params: ResolveActionParams<U> } : { params?: never }; | ||
|
|
||
| export type ActionUrl = | ||
| | { | ||
| [K in keyof PageActionMap]: PageActionMap[K] extends { body: any } ? K : never; | ||
| }[keyof PageActionMap] | ||
| | { | ||
| [K in keyof PageActionMap]: PageActionMap[K] extends { actions: infer A } | ||
| ? `${K & string}?${keyof A & string}` | ||
| : never; | ||
| }[keyof PageActionMap] | ||
|
|
||
| interface RouteMap { | ||
| } | ||
|
|
||
| interface WebSocketRouteMap { | ||
| } | ||
| } |
This file contains hidden or 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,16 @@ | ||
| { | ||
| "files": [ | ||
| "routes.d.ts", | ||
| "md.d.ts" | ||
| ], | ||
| "compilerOptions": { | ||
| "paths": { | ||
| "void/routes": [ | ||
| "./routes.d.ts" | ||
| ], | ||
| "@void/md/pages": [ | ||
| "./md.d.ts" | ||
| ] | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node.js version
24.14.0is not a valid or released version. This is likely a typo for a current version like22.14.0or20.14.0. Using a non-existent version will cause environment setup tools to fail.