Skip to content

Commit ccac58b

Browse files
committed
Split docs CI and GitHub-driven Vercel deploy
1 parent 7cbe820 commit ccac58b

File tree

10 files changed

+134
-22
lines changed

10 files changed

+134
-22
lines changed

.github/actions/setup-node-pnpm/action.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ inputs:
1818
description: Whether to run pnpm install
1919
required: false
2020
default: "true"
21+
install-filter:
22+
description: Optional pnpm filter selector to limit install scope
23+
required: false
24+
default: ""
2125

2226
runs:
2327
using: composite
@@ -36,6 +40,13 @@ runs:
3640
registry-url: ${{ inputs.registry-url }}
3741

3842
- name: Install workspace dependencies
39-
if: inputs.install == 'true'
43+
if: inputs.install == 'true' && inputs['install-filter'] == ''
4044
shell: bash
4145
run: pnpm install --frozen-lockfile --ignore-scripts
46+
47+
- name: Install filtered workspace dependencies
48+
if: inputs.install == 'true' && inputs['install-filter'] != ''
49+
shell: bash
50+
run: pnpm install --frozen-lockfile --ignore-scripts --filter "$INSTALL_FILTER"
51+
env:
52+
INSTALL_FILTER: ${{ inputs['install-filter'] }}

.github/workflows/deploy-doc.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ on:
66
- main
77
paths:
88
- doc/**
9+
- .github/actions/setup-node-pnpm/action.yml
10+
- .github/workflows/deploy-doc.yml
11+
- .github/workflows/pull-request-doc.yml
12+
- package.json
13+
- pnpm-lock.yaml
14+
- pnpm-workspace.yaml
15+
- turbo.json
916
workflow_dispatch:
1017

1118
permissions:
@@ -25,9 +32,11 @@ jobs:
2532
runs-on: ubuntu-24.04
2633
timeout-minutes: 30
2734
steps:
28-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@v6
2936

3037
- uses: ./.github/actions/setup-node-pnpm
38+
with:
39+
install-filter: "@truenine/memory-sync-docs..."
3140

3241
- name: Preflight Vercel secrets
3342
shell: bash
@@ -49,11 +58,20 @@ jobs:
4958
exit 1
5059
fi
5160
61+
- name: Lint docs
62+
run: pnpm -C doc run lint
63+
64+
- name: Typecheck docs
65+
run: pnpm -C doc run typecheck
66+
5267
- name: Pull Vercel production settings
68+
working-directory: ./doc
5369
run: pnpm dlx vercel@latest pull --yes --environment=production --token="$VERCEL_TOKEN"
5470

5571
- name: Build docs on Vercel
72+
working-directory: ./doc
5673
run: pnpm dlx vercel@latest build --prod --token="$VERCEL_TOKEN"
5774

5875
- name: Deploy docs to Vercel production
76+
working-directory: ./doc
5977
run: pnpm dlx vercel@latest deploy --prebuilt --prod --token="$VERCEL_TOKEN"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Pull Request Docs
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types: [opened, synchronize, reopened, ready_for_review]
8+
paths:
9+
- doc/**
10+
- .github/actions/setup-node-pnpm/action.yml
11+
- .github/workflows/deploy-doc.yml
12+
- .github/workflows/pull-request-doc.yml
13+
- package.json
14+
- pnpm-lock.yaml
15+
- pnpm-workspace.yaml
16+
- turbo.json
17+
18+
permissions:
19+
contents: read
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
check-doc:
27+
if: github.event.pull_request.draft == false
28+
runs-on: ubuntu-24.04
29+
timeout-minutes: 30
30+
steps:
31+
- uses: actions/checkout@v6
32+
33+
- uses: ./.github/actions/setup-node-pnpm
34+
with:
35+
install-filter: "@truenine/memory-sync-docs..."
36+
37+
- name: Validate docs content
38+
run: pnpm -C doc run validate:content
39+
40+
- name: Lint docs
41+
run: pnpm -C doc run lint
42+
43+
- name: Typecheck docs
44+
run: pnpm -C doc run typecheck
45+
46+
- name: Build docs
47+
run: pnpm -C doc run build

.github/workflows/pull-request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414
- CODE_OF_CONDUCT.md
1515
- LICENSE
1616
- SECURITY.md
17+
- doc/**
18+
- .github/workflows/deploy-doc.yml
19+
- .github/workflows/pull-request-doc.yml
1720

1821
permissions:
1922
contents: read

doc/components/docs-callout.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ type CalloutTone = 'note' | 'tip' | 'important' | 'warning' | 'caution'
66
type BlockquoteProps = ComponentPropsWithoutRef<'blockquote'>
77

88
const CALLOUT_PATTERN = /^\s*\[!(note|tip|important|warning|caution)\]\s*/i
9+
const CALLOUT_TONES = new Set<CalloutTone>(['note', 'tip', 'important', 'warning', 'caution'])
910

1011
const CALLOUT_LABELS: Record<CalloutTone, string> = {
1112
note: 'Note',
@@ -43,42 +44,51 @@ function getMeaningfulChildren(children: ReactNode): ReactNode[] {
4344

4445
function stripMarkerFromChildren(children: ReactNode): ReactNode {
4546
const items = getMeaningfulChildren(children)
47+
const strippedItems: ReactNode[] = []
4648

47-
return items.map(async (item, index) => {
49+
for (const [index, item] of items.entries()) {
4850
if (index !== 0) {
49-
return item
51+
strippedItems.push(item)
52+
continue
5053
}
5154

5255
if (typeof item === 'string') {
53-
return item.replace(CALLOUT_PATTERN, '')
56+
strippedItems.push(item.replace(CALLOUT_PATTERN, ''))
57+
continue
5458
}
5559

5660
if (!isValidElement(item)) {
57-
return item
61+
strippedItems.push(item)
62+
continue
5863
}
5964

6065
const element = item as ReactElement<{children?: ReactNode}>
6166
const text = extractText(element.props.children)
6267

6368
if (!CALLOUT_PATTERN.test(text)) {
64-
return item
69+
strippedItems.push(item)
70+
continue
6571
}
6672

67-
return cloneElement(element, {
73+
strippedItems.push(cloneElement(element, {
6874
...element.props,
6975
children: text.replace(CALLOUT_PATTERN, '')
70-
})
71-
})
76+
}))
77+
}
78+
79+
return strippedItems
80+
}
81+
82+
function isCalloutTone(value: string | undefined): value is CalloutTone {
83+
return value != null && CALLOUT_TONES.has(value as CalloutTone)
7284
}
7385

7486
function resolveCalloutTone(children: ReactNode): CalloutTone | null {
7587
const firstChild = getMeaningfulChildren(children)[0]
7688
const firstText = extractText(firstChild).trimStart()
7789
const matched = CALLOUT_PATTERN.exec(firstText)?.[1]?.toLowerCase()
7890

79-
if (
80-
new Set(['note', 'tip', 'important', 'warning', 'caution']).has(matched)
81-
) {
91+
if (isCalloutTone(matched)) {
8292
return matched
8393
}
8494

doc/components/home-contributors.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,15 @@ function getRepoCoordinates(repoUrl: string) {
6161

6262
function getGitHubHeaders() {
6363
const token = process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN
64-
const authorization = token != null && token !== ''
65-
? {Authorization: `Bearer ${token}`}
66-
: {}
64+
const headers: Record<string, string> = {
65+
Accept: 'application/vnd.github+json'
66+
}
6767

68-
return {
69-
Accept: 'application/vnd.github+json',
70-
...authorization
68+
if (token != null && token !== '') {
69+
headers.Authorization = `Bearer ${token}`
7170
}
71+
72+
return headers
7273
}
7374

7475
async function fetchContributorsPage(page: number): Promise<GitHubContributor[]> {

doc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"postbuild": "pagefind --site .next/server/app --output-path public/_pagefind",
1313
"check": "run-p lint typecheck",
1414
"validate:content": "tsx scripts/validate-content.ts",
15-
"typecheck": "next typegen && tsc --noEmit --incremental false",
15+
"typecheck": "next typegen && tsc --project tsconfig.typecheck.json --noEmit --incremental false",
1616
"start": "next start",
1717
"lint": "pnpm run validate:content && eslint ."
1818
},

doc/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"**/*.tsx",
3434
"**/*.mdx",
3535
"**/_meta.ts",
36-
".next/types/**/*.ts",
37-
".next/dev/types/**/*.ts"
36+
".next/dev/types/**/*.ts",
37+
".next/types/**/*.ts"
3838
],
3939
"exclude": [
4040
"node_modules"

doc/tsconfig.typecheck.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": [
4+
"next-env.d.ts",
5+
"**/*.d.ts",
6+
"**/*.ts",
7+
"**/*.tsx",
8+
"**/*.mdx",
9+
"**/_meta.ts",
10+
".next/dev/types/**/*.ts"
11+
],
12+
"exclude": [
13+
"node_modules",
14+
".next/types/**/*.ts"
15+
]
16+
}

doc/vercel.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://openapi.vercel.sh/vercel.json",
3+
"git": {
4+
"deploymentEnabled": false
5+
}
6+
}

0 commit comments

Comments
 (0)