|
| 1 | +# GitHub Pages 配置指南 |
| 2 | + |
| 3 | +## ⚠️ 重要:必须手动启用 GitHub Pages |
| 4 | + |
| 5 | +虽然我们已经配置了 GitHub Actions,但 GitHub Pages 需要在仓库设置中手动启用。 |
| 6 | + |
| 7 | +## 📋 配置步骤 |
| 8 | + |
| 9 | +### 1. 进入仓库设置 |
| 10 | + |
| 11 | +访问:https://github.com/fuck-algorithm/leetcode-56-merge-intervals/settings/pages |
| 12 | + |
| 13 | +或者: |
| 14 | +1. 打开仓库主页 |
| 15 | +2. 点击 **Settings** (设置) |
| 16 | +3. 左侧菜单找到 **Pages** |
| 17 | + |
| 18 | +### 2. 配置 Source |
| 19 | + |
| 20 | +在 **Build and deployment** 部分: |
| 21 | + |
| 22 | +1. **Source** 下拉菜单选择:**GitHub Actions** |
| 23 | + - ⚠️ 不要选择 "Deploy from a branch" |
| 24 | + - ✅ 必须选择 "GitHub Actions" |
| 25 | + |
| 26 | +2. 点击 **Save** (如果有保存按钮) |
| 27 | + |
| 28 | +### 3. 验证配置 |
| 29 | + |
| 30 | +配置完成后应该看到: |
| 31 | + |
| 32 | +``` |
| 33 | +✓ Your site is live at https://fuck-algorithm.github.io/leetcode-56-merge-intervals/ |
| 34 | +``` |
| 35 | + |
| 36 | +### 4. 触发部署 |
| 37 | + |
| 38 | +配置完成后,有两种方式触发部署: |
| 39 | + |
| 40 | +**方法1:手动触发(推荐)** |
| 41 | +1. 进入 **Actions** 标签页 |
| 42 | +2. 选择 "Deploy to GitHub Pages" workflow |
| 43 | +3. 点击 **Run workflow** 按钮 |
| 44 | +4. 点击绿色的 **Run workflow** 确认 |
| 45 | + |
| 46 | +**方法2:推送代码** |
| 47 | +```bash |
| 48 | +git commit --allow-empty -m "trigger: 触发部署" |
| 49 | +git push origin main |
| 50 | +``` |
| 51 | + |
| 52 | +### 5. 等待部署完成 |
| 53 | + |
| 54 | +1. 在 **Actions** 页面查看运行状态 |
| 55 | +2. 等待两个作业完成: |
| 56 | + - ✅ build (构建项目) |
| 57 | + - ✅ deploy (部署到Pages) |
| 58 | +3. 通常需要 1-2 分钟 |
| 59 | + |
| 60 | +### 6. 访问网站 |
| 61 | + |
| 62 | +部署成功后访问: |
| 63 | +``` |
| 64 | +https://fuck-algorithm.github.io/leetcode-56-merge-intervals/ |
| 65 | +``` |
| 66 | + |
| 67 | +## ✅ 检查清单 |
| 68 | + |
| 69 | +确认以下配置都正确: |
| 70 | + |
| 71 | +- [x] `.github/workflows/deploy.yml` 文件存在 |
| 72 | +- [x] `package.json` 中 `homepage` 配置正确 |
| 73 | +- [x] `public/index.html` 文件已提交 |
| 74 | +- [ ] GitHub Pages 设置为 "GitHub Actions" ⚠️ **需要手动配置** |
| 75 | +- [ ] GitHub Actions workflow 已成功运行 |
| 76 | +- [ ] 网站可以访问 |
| 77 | + |
| 78 | +## 🐛 故障排查 |
| 79 | + |
| 80 | +### 问题1: 404 Not Found |
| 81 | + |
| 82 | +**可能原因:** |
| 83 | +- GitHub Pages 没有正确配置为使用 GitHub Actions |
| 84 | +- 部署还在进行中 |
| 85 | + |
| 86 | +**解决方案:** |
| 87 | +1. 检查 Settings → Pages → Source 是否为 "GitHub Actions" |
| 88 | +2. 查看 Actions 页面确认部署是否成功 |
| 89 | +3. 等待 2-5 分钟让 DNS 更新 |
| 90 | + |
| 91 | +### 问题2: Actions 运行失败 |
| 92 | + |
| 93 | +**解决方案:** |
| 94 | +1. 查看 Actions 页面的错误日志 |
| 95 | +2. 确认 `public/index.html` 文件存在 |
| 96 | +3. 本地运行 `npm run build` 测试 |
| 97 | + |
| 98 | +### 问题3: 页面空白 |
| 99 | + |
| 100 | +**可能原因:** |
| 101 | +- JavaScript 路径错误 |
| 102 | +- `homepage` 配置不正确 |
| 103 | + |
| 104 | +**解决方案:** |
| 105 | +1. 检查浏览器控制台错误 |
| 106 | +2. 确认 `package.json` 中 `homepage` 为: |
| 107 | + ```json |
| 108 | + "homepage": "https://fuck-algorithm.github.io/leetcode-56-merge-intervals" |
| 109 | + ``` |
| 110 | + |
| 111 | +## 📊 当前配置状态 |
| 112 | + |
| 113 | +### ✅ 已完成 |
| 114 | +- GitHub Actions workflow 配置 |
| 115 | +- package.json homepage 配置 |
| 116 | +- 本地构建测试通过 |
| 117 | +- 所有必需文件已提交 |
| 118 | + |
| 119 | +### ⏳ 待完成 |
| 120 | +- GitHub Pages 手动配置(Settings → Pages → Source → GitHub Actions) |
| 121 | +- 首次部署运行 |
| 122 | +- 网站访问验证 |
| 123 | + |
| 124 | +## 🔗 相关链接 |
| 125 | + |
| 126 | +- 仓库地址:https://github.com/fuck-algorithm/leetcode-56-merge-intervals |
| 127 | +- Actions 页面:https://github.com/fuck-algorithm/leetcode-56-merge-intervals/actions |
| 128 | +- Pages 设置:https://github.com/fuck-algorithm/leetcode-56-merge-intervals/settings/pages |
| 129 | +- 目标网址:https://fuck-algorithm.github.io/leetcode-56-merge-intervals/ |
| 130 | + |
| 131 | +## 📝 下一步 |
| 132 | + |
| 133 | +1. **立即执行**:访问 Settings → Pages,选择 "GitHub Actions" |
| 134 | +2. **触发部署**:手动运行 workflow 或推送代码 |
| 135 | +3. **验证结果**:等待部署完成后访问网站 |
0 commit comments