11name : 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+
36on :
47 pull_request :
58 paths :
1720 - " .github/workflows/docs.yml"
1821 workflow_dispatch :
1922
23+ concurrency :
24+ group : docs-${{ github.ref }}
25+ cancel-in-progress : true
26+
2027permissions :
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 "/*"
0 commit comments