Skip to content

Commit ffe4819

Browse files
abs2023cursoragent
andcommitted
ci: validate, build, and deploy Mintlify docs via OIDC
Add docs npm toolchain (mint export, Pagefind, llms.txt), combine validate and S3/CloudFront deploy in docs.yml, and exclude docs workflows from the main CI-CD path filter so doc-only changes do not trigger node builds. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 07e9b5d commit ffe4819

9 files changed

Lines changed: 13791 additions & 10 deletions

File tree

.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ on:
4141
- dev
4242
- cicd/*
4343

44-
paths: [".github/**", "ui-desktop/**", "ui-core/**", "proxy-router/**", "cli/**"]
44+
paths:
45+
- ".github/**"
46+
- "!.github/workflows/docs.yml"
47+
- "ui-desktop/**"
48+
- "ui-core/**"
49+
- "proxy-router/**"
50+
- "cli/**"
4551

4652
# pull_request:
4753
# types: [opened, reopened, synchronize]

.github/workflows/docs.yml

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Docs
22

3+
# Validate Mintlify docs on PRs and pushes. Deploy to S3 + CloudFront (OIDC) on
4+
# test/main after validation passes. Does not trigger the main CI-CD pipeline.
5+
36
on:
47
pull_request:
58
paths:
@@ -17,6 +20,10 @@ on:
1720
- ".github/workflows/docs.yml"
1821
workflow_dispatch:
1922

23+
concurrency:
24+
group: docs-${{ github.ref }}
25+
cancel-in-progress: true
26+
2027
permissions:
2128
contents: read
2229
pull-requests: write
@@ -33,16 +40,18 @@ jobs:
3340
uses: actions/setup-node@v4
3441
with:
3542
node-version: "20"
43+
cache: npm
44+
cache-dependency-path: docs/package-lock.json
3645

37-
- name: Install Mintlify CLI
38-
run: npm install -g mint@latest
46+
- name: Install docs dependencies
47+
working-directory: docs
48+
run: npm ci
3949

4050
- name: Validate Mintlify config
4151
working-directory: docs
4252
run: |
43-
# Mintlify CLI command may evolve; we accept either name
44-
mint --version
45-
mint broken-links || echo "::warning::mint broken-links reported issues"
53+
npx mint --version
54+
npx mint broken-links || echo "::warning::mint broken-links reported issues"
4655
4756
- name: List MDX files
4857
run: find docs -name "*.mdx" | wc -l
@@ -77,20 +86,17 @@ jobs:
7786
- name: Find pages with last_verified older than the latest release tag
7887
run: |
7988
set -euo pipefail
80-
# Determine the latest non-test release tag, fall back to v0.0.0
8189
LATEST_TAG=$(git tag --list 'v*' --sort=-v:refname | grep -v -- '-test' | head -n 1 || true)
8290
LATEST_TAG=${LATEST_TAG:-v0.0.0}
8391
echo "Latest release tag: $LATEST_TAG"
8492
8593
STALE_FILES=()
8694
while IFS= read -r f; do
87-
# Read first 30 lines for frontmatter and grep last_verified
8895
VERIFIED=$(awk '/^---$/{n++; next} n==1 && /^last_verified:/ {print}' "$f" \
8996
| sed -E 's/^last_verified:[[:space:]]*"?([^"]*)"?$/\1/' || true)
9097
if [ -z "$VERIFIED" ]; then
9198
continue
9299
fi
93-
# Compare lexicographically; vN.N.N strings sort correctly enough for warnings
94100
if [ "$VERIFIED" \< "$LATEST_TAG" ]; then
95101
STALE_FILES+=("$f (last_verified=$VERIFIED < $LATEST_TAG)")
96102
fi
@@ -104,3 +110,56 @@ jobs:
104110
else
105111
echo "All pages report last_verified >= $LATEST_TAG."
106112
fi
113+
114+
deploy:
115+
name: Build and deploy docs
116+
needs:
117+
- mintlify-validate
118+
- openapi-lint
119+
- last-verified-staleness
120+
if: github.event_name == 'push' && (github.ref_name == 'test' || github.ref_name == 'main')
121+
runs-on: ubuntu-latest
122+
environment: ${{ github.ref_name }}
123+
permissions:
124+
contents: read
125+
id-token: write
126+
steps:
127+
- name: Checkout
128+
uses: actions/checkout@v4
129+
130+
- name: Setup Node
131+
uses: actions/setup-node@v4
132+
with:
133+
node-version: "20"
134+
cache: npm
135+
cache-dependency-path: docs/package-lock.json
136+
137+
- name: Install docs dependencies
138+
working-directory: docs
139+
run: npm ci
140+
141+
- name: Build static site
142+
working-directory: docs
143+
env:
144+
SITE_URL: ${{ vars.NODEDOCS_SITE_URL }}
145+
run: npm run build:site -- ../.site
146+
147+
- name: Configure AWS credentials (OIDC)
148+
uses: aws-actions/configure-aws-credentials@v4
149+
with:
150+
role-to-assume: ${{ vars.NODEDOCS_IAM_ROLE_ARN }}
151+
aws-region: us-east-2
152+
153+
- name: Sync to S3
154+
run: |
155+
aws s3 sync .site/ "s3://${{ vars.NODEDOCS_S3_BUCKET }}/" \
156+
--delete \
157+
--exclude "serve.js" \
158+
--exclude "Start Docs.command" \
159+
--exclude "Start Docs.bat"
160+
161+
- name: Invalidate CloudFront
162+
run: |
163+
aws cloudfront create-invalidation \
164+
--distribution-id "${{ vars.NODEDOCS_CLOUDFRONT_DISTRIBUTION_ID }}" \
165+
--paths "/*"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
***/.env
55
***/.$*drawio.bkp
66
***/.$*drawio.dtmp
7-
*.internal.*
7+
*.internal.*
8+
.site/

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
node_modules/
33
.DS_Store
44
*.log
5+
.site/

0 commit comments

Comments
 (0)