Skip to content

🚀 部署指南

English | 简体中文

本项目已配置 GitHub Actions 自动部署,每次推送到 main 分支时自动部署到 GitHub Pages。

📊 部署状态

Deploy to GitHub Pages

  • 🟢 passing - 部署成功
  • 🔴 failing - 部署失败
  • 🟡 in progress - 正在部署中

🎯 首次部署(必读)

⚠️ 重要:必须先启用 GitHub Pages!

正确顺序

  1. ✅ 先启用 GitHub Pages
  2. ✅ 再推送代码部署

步骤 1: 启用 GitHub Pages

  1. 访问仓库设置:

    https://github.com/naodeng/awesome-qa-prompt/settings/pages
  2. "Build and deployment" 部分:

    • Source: 选择 "GitHub Actions"(不是 "Deploy from a branch")
    • 点击保存
  3. 确认设置已保存(页面显示 "Your site is ready to be published")

步骤 2: 推送代码

bash
git add .
git commit -m "feat: 配置 GitHub Pages 自动部署"
git push origin main

步骤 3: 等待部署

步骤 4: 访问网站

部署成功后访问:

https://naodeng.github.io/awesome-qa-prompt/

🔄 日常更新

配置完成后,每次更新只需:

bash
# 1. 修改文档
vim README.md

# 2. 提交推送
git add .
git commit -m "docs: 更新文档内容"
git push origin main

# 3. 自动部署(无需手动操作)
# GitHub Actions 会自动完成部署

📊 部署工作流说明

工作流程

┌─────────────────────────────────────┐
│  Push to main branch                │
└──────────────┬──────────────────────┘


┌─────────────────────────────────────┐
│  Job 1: Build VitePress Site        │
├─────────────────────────────────────┤
│  📥 Checkout repository             │
│  🟢 Setup Node.js (v20)             │
│  ⚙️  Setup Pages                     │
│  📦 Install dependencies (npm ci)   │
│  🏗️  Build site (npm run docs:build)│
│  📤 Upload artifact                 │
└──────────────┬──────────────────────┘


┌─────────────────────────────────────┐
│  Job 2: Deploy to GitHub Pages      │
├─────────────────────────────────────┤
│  🚀 Deploy to GitHub Pages          │
│  🎉 Deployment complete             │
└──────────────┬──────────────────────┘


┌─────────────────────────────────────┐
│  ✅ Site live at:                   │
│  https://naodeng.github.io/         │
│  awesome-qa-prompt/                 │
└─────────────────────────────────────┘

触发条件

  • ✅ 推送到 main 分支
  • ✅ 手动触发(在 Actions 页面点击 "Run workflow")

构建时间

  • 首次构建:约 2-3 分钟
  • 后续构建:约 1-2 分钟

查看部署日志

  1. 访问 Actions 页面:https://github.com/naodeng/awesome-qa-prompt/actions
  2. 点击最新的工作流运行
  3. 查看每个步骤的详细日志(带有 emoji 图标,更易识别)

💻 本地开发

安装依赖

bash
npm install

启动开发服务器

bash
npm run docs:dev

访问 http://localhost:5173 查看效果。

构建生产版本

bash
npm run docs:build

预览生产版本

bash
npm run docs:preview

🐛 故障排除

问题 1: "Get Pages site failed" 或 "Not Found" 错误

错误信息

Error: Get Pages site failed
Error: HttpError: Not Found

原因:GitHub Pages 还未启用

解决方案

  1. 访问 https://github.com/naodeng/awesome-qa-prompt/settings/pages
  2. Source 选择 "GitHub Actions"
  3. 点击保存
  4. 在 Actions 页面点击 "Re-run all jobs" 重新运行

问题 2: 部署失败

查看日志

  1. 访问 https://github.com/naodeng/awesome-qa-prompt/actions
  2. 点击失败的工作流
  3. 查看错误信息

常见原因

  • 依赖安装失败:删除 node_modules 重新安装
  • 构建错误:检查 Markdown 文件语法
  • 权限问题:确认 Actions 有读写权限

问题 3: 网站显示 404

解决方案

  1. 确认 GitHub Pages Source 设置为 "GitHub Actions"
  2. 检查 .vitepress/config.mtsbase: '/awesome-qa-prompt/'
  3. 清除浏览器缓存重试

问题 4: 样式丢失

解决方案

  1. 确认 base 路径配置正确
  2. 清除浏览器缓存
  3. 重新部署

📋 部署检查清单

首次部署前

  • [ ] GitHub Pages 已启用
  • [ ] Source 设置为 "GitHub Actions"
  • [ ] .vitepress/config.mtsbase 配置正确
  • [ ] 代码已推送到 main 分支

首次部署后

  • [ ] Actions 工作流运行成功(绿色勾号)
  • [ ] 网站可以正常访问
  • [ ] 所有功能正常工作
  • [ ] README 徽章显示 "passing"

🔗 相关链接


💡 提示

  1. 首次配置:必须先启用 Pages,再运行 Actions
  2. Source 选择:一定要选 "GitHub Actions",不是 "Deploy from a branch"
  3. 自动部署:配置完成后,每次推送自动部署
  4. 部署时间:通常 2-3 分钟完成

需要帮助? 查看 Actions 日志 获取详细错误信息。

基于 MIT 许可发布