CI/CD Pipelines
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The CI/CD pipelines in the WHK project facilitate the automated building, testing, and deployment of a science-oriented knowledge base. The system transitions from a collection of Markdown documents to a highly optimized static website and downloadable PDF assets. These pipelines ensure that content adheres to strict typographic standards while maintaining high performance through server-side rendering and asset minification.
Sources: README.md:1-50, README.md:144-155
The project utilizes GitHub Actions as the primary orchestration engine, supporting multi-environment deployments to GitHub Pages and Cloudflare Pages. The workflow integrates complex asset processing, including KaTeX server-side rendering for mathematical and chemical formulas, and specialized AI-driven metadata generation for SEO optimization.
Sources: README.md:144-155, scripts/frontmatter/generate_frontmatter.js:15-25
Core Workflows
The system is primarily driven by two major automated workflows: a CI/CD pipeline for site deployment and an export pipeline for document generation.
CI/CD Pipeline (ci.yml)
This workflow is the primary path for site updates. It is triggered by pushes to the main branch, weekly schedules, or manual intervention. Its core responsibilities include:
- Static Site Generation: Building the project using MkDocs with the Material theme.
- Multi-Environment Deployment: Parallel deployment to both GitHub Pages and Cloudflare Pages.
- Validation: Running linting checks to ensure Markdown compliance.
Sources: README.md:146-150, README.md:113-125
Export Pipeline (export.yml)
Triggered by version tags (e.g., v*) or manual triggers, this pipeline handles asset distribution:
- PDF Conversion: Utilizing Puppeteer to transform web pages into PDF format.
- LaTeX Rendering: Generating professional-grade documents with bookmarks and indices.
- Release Management: Automatically attaching generated PDFs to GitHub Releases.
Sources: README.md:152-155, README.md:195-200
Build and Optimization Architecture
The build process is an "in-place" optimization model that modifies files within the target directory to maximize delivery speed.
This diagram illustrates the sequential flow from site generation through the multi-stage optimization pipeline.
Sources: build.ts:1-25, build.ts:380-410
Build Script Components
The build.ts script, executed via Bun, performs deep optimization on static assets:
| Component | Technology | Optimization Actions |
|---|---|---|
| CSS | PostCSS, cssnano | Autoprefixer, nesting support, z-index management, and rule merging. |
| JS | Terser | Deep compression, source map generation, and name mangling. |
| HTML | PostHTML | Alt tag generation, metadata deduplication, style tag merging, and head reordering. |
| Final Minification | html-minifier-terser | Whitespace collapse, comment removal, and redundant attribute stripping. |
Sources: build.ts:10-25, build.ts:50-65, build.ts:320-350
AI-Enhanced Integration Workflows
The project features a specialized "Supplement Integration" workflow that uses AI agents to merge draft content into the main documentation while maintaining style consistency.
The sequence of phases required to integrate supplemental content via AI automation.
Sources: scripts/workflows/supplement-integration-v2.md:15-50, scripts/workflows/supplement-integration-v2.md:160-180
Content Validation and Linting
The review.js tool is a critical gatekeeper in the CI process, enforcing technical and typographic rules:
- Autocorrect: Managing spacing between CJK and alphanumeric characters.
- Formula Check: Validating KaTeX syntax and custom macros.
- Structure: Enforcing 4-space indentation and heading hierarchies.
Sources: REVIEW.md:40-60, scripts/review/SKILL.md:10-30
Metadata and SEO Automation
Before final deployment, the project employs an "Expert Mode" metadata generator (generate_frontmatter.js) to ensure high SEO visibility and LLM-friendliness.
Frontmatter Generation Pipeline
- Scanning: Identifies new or modified files within the
sciencedirectory. - Extraction: Pulls the H1 title and the first 1000 characters of content.
- LLM Processing: Sends context to an NVIDIA NIM model to generate:
- SEO Title: 20-25 character creative title.
- Description: 100-200 character technical summary.
- Tags: 15-25 atomic tags across five dimensions (Subject, Core Term, Detail, Scenario, Target).
- Injection: Atomically writes the YAML frontmatter back to the source file.
Sources: scripts/frontmatter/generate_frontmatter.js:15-35, scripts/frontmatter/generate_frontmatter.js:140-180
Summary
The CI/CD infrastructure of the WHK project represents a sophisticated marriage of traditional static site generation and modern AI automation. By leveraging GitHub Actions for orchestration, Bun for high-performance asset optimization, and custom AI workflows for content integration and SEO, the project ensures that its educational content is delivered with technical precision, high accessibility, and consistent typographic quality.