ci: 优化部署流水线配置以提升构建与发布效率
生产环境部署 - BlogFlare 至 Cloudflare Pages / 构建与自动化上线 (push) Successful in 51s

This commit is contained in:
seahi committed 2026-08-05 14:24:33 +08:00
1 parent a7a3cb3ef6
commit f5128ebdb1
1 file changed
+11 -9
+11 -9
View File
@@ -13,9 +13,11 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
# 1. 检出仓库最新代码 # 1. 检出仓库最新代码 (已提速:明确限定 fetch-depth: 1 只取最近一条提交历史)
- name: 1. 检出源代码 - name: 1. 检出源代码
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
fetch-depth: 1
# 2. 初始化 Node.js 运行环境 (使用 Node 22) # 2. 初始化 Node.js 运行环境 (使用 Node 22)
- name: 2. 初始化 Node.js 环境 - name: 2. 初始化 Node.js 环境
@@ -23,21 +25,21 @@ jobs:
with: with:
node-version: '22' node-version: '22'
# 3. 安装 pnpm 包管理器 (直接复用镜像层或官方 npm,避免 Gitea 自建 Runner 拉取 github-release 超时) # 3. 全局安装 pnpm 11 与您本地版本完美看齐
- name: 3. 全局安装并准备 pnpm - name: 3. 全局安装 pnpm (对应当前开发态 11 体系)
run: npm install -g pnpm@9 run: npm install -g pnpm@11
# 4. 严格按照项目公约,通过 pnpm install 安装工程依赖 # 4. 安装工程依赖包 (结合锁定配置防止额外联网比对,提速构建)
- name: 4. 安装工程依赖包 - name: 4. 安装工程依赖包
run: pnpm install run: pnpm install --frozen-lockfile
# 5. 执行类型自检并打包输出静态产物及适配器运行脚本 (产出在 .svelte-kit/cloudflare) # 5. 执行类型自检并打包输出静态产物 (产出在 .svelte-kit/cloudflare)
- name: 5. 构建生产环境打包产物 - name: 5. 构建生产环境打包产物
run: pnpm run build run: pnpm run build
# 6. 使用 pnpm dlx 驱动官方 wrangler 发布静态构建至 Cloudflare # 6. 【极速爆发大招】直接唤起本地装齐的 wrangler 执行直推,抹去漫长 dlx 下载时延!
- name: 6. 自动化推送到 Cloudflare Pages (主分支为生产发布) - name: 6. 自动化推送到 Cloudflare Pages (主分支为生产发布)
env: env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: pnpm dlx wrangler pages deploy .svelte-kit/cloudflare --project-name=blogflare --branch=main run: pnpm exec wrangler pages deploy .svelte-kit/cloudflare --project-name=blogflare --branch=main