Skip to content

fix: update Rust action to use rust-toolchain for consistency #6

fix: update Rust action to use rust-toolchain for consistency

fix: update Rust action to use rust-toolchain for consistency #6

Workflow file for this run

name: Documentation
on:
push:
branches: [main]
paths:
- 'docs/**'
- '.github/workflows/docs.yml'
- 'rspress.config.ts'
pull_request:
branches: [main]
paths:
- 'docs/**'
env:
NODE_VERSION: '20'
jobs:
# ========== 构建文档 ==========
build:
name: Build Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: false
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build qrcode-wasm
run: pnpm --filter @veaba/qrcode-wasm exec npm run build
- name: Build documentation
run: pnpm docs:build
- name: Upload documentation artifacts
uses: actions/upload-artifact@v4
with:
name: documentation
path: doc_build
# ========== 部署到 Cloudflare Pages ==========
deploy:
name: Deploy to Cloudflare Pages
runs-on: ubuntu-latest
needs: build
# 只在 push 到 main 分支时部署(PR 不部署)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Download documentation artifacts
uses: actions/download-artifact@v4
with:
name: documentation
path: doc_build
- name: Deploy to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
projectName: qrcodes-docs
directory: doc_build
gitHubToken: ${{ secrets.GITHUB_TOKEN }}