Skill · 写完一篇 → 上线全流程

何时用:写完一篇文章想发出去;或者要排查"我 push 了为啥 sbrave.cn 没更新"。

解决什么:把"敲完最后一个字 → sbrave.cn 上看到"这条端到端链路拆成可观察的步骤。

端到端时序

你按 Cmd+S
   │
   │ (a) Obsidian 写盘
   │
   │ (b) 如果开了 auto-push,30s 后插件触发 push 流程
   │     (没开就走命令面板手动调"Push blog repo")
   ▼
插件: gitInitIfMissing → gitStageAndDiff
   │  (c) git add -A,跑 git diff --cached
   ▼
DiffConfirmModal 弹出 (默认开启)
   │  (d) 你 review,点 Commit & Push
   │      (Cancel 会 git reset 解暂存,工作树不动)
   ▼
插件: gitCommitAndPush
   │  (e) 生成 commit 信息(模板 obsidian sync: {{count}} file(s) at {{date}})
   │  (f) git commit -m "..."  + git push HEAD:master
   ▼
sbraveyoung/blog 的 .github/workflows/deploy.yml
   │  (g) 仅有一个 step: 用 GH_PAT 调
   │      POST /repos/sbraveyoung/sbraveyoung.github.io/dispatches
   │      event_type=blog-update
   ▼
sbraveyoung.github.io 的 .github/workflows/deploy.yml
   │  (h) checkout sbraveyoung/blog + sbraveyoung/gobog
   │  (i) 读 _gobog.json → 拼 _gobog.toml → go build → ./gobog -export _dist
   │  (j) scripts/check-export.sh _dist (死链 / 孤儿 / 可疑 URL 审计)
   │  (k) 用 _dist/ 替换工作树(.git/.github/_gobog.json/scripts 保留)
   │  (l) git commit + git push
   ▼
GitHub Pages 自动伺服
   ▼
sbrave.cn

整体时间:从 (a) 到 sbrave.cn 上看到,1~2 分钟为常态。

触发器

触发 来源
主路径 blog 仓库 push → repository_dispatch → github.io 跑 deploy
手动 github.io 仓库的 Actions 页 → Deploy → Run workflow
兜底 每天 06:00 UTC 跑一次 schedule,防止某次 webhook 没送达

该看哪个 Actions 页排查

  • blog push 后 sbrave.cn 没更新:先看 sbraveyoung/blog/actions,确认 notify workflow 跑成功。如果是 secrets.GH_PAT not configured 这类错,去 blog 仓库 settings → secrets 加一下 GH_PAT。
  • notify 跑成功但 github.io 没动:看 sbraveyoung/sbraveyoung.github.io/actions,repository_dispatch 触发的 run 应该在那里。失败原因一般是 token 权限不够或者 _gobog.toml 拼接出错。
  • github.io 跑成功但页面看着是旧的:GitHub Pages 自己有缓存,等 1~2 分钟,或者 hard refresh。

必需的 secret

仓库 secret 名 干啥
sbraveyoung/blog GH_PAT Fine-grained PAT,对 sbraveyoung/sbraveyoung.github.io 有 Contents: R/W。
sbraveyoung/sbraveyoung.github.io GH_PAT Fine-grained PAT,对 blog + gobog 有 Contents: Read,对自己有 R/W。

公开仓库的话,github.io 可以 fallback 到默认的 GITHUB_TOKEN,但配 GH_PAT 更稳。

常见坑

  • Diff 弹出后我点了 Cancel,但下次 push 还是显示一样的 diff:正常。Cancel 走的是 git reset,工作树不动;下次 stage 自然还是同一份变更。
  • 插件说 "pull is not fast-forward":你本地有 commit 远端也有 commit。手动 git rebase origin/master 解决,别图省事让插件强 reset。
  • deploy 失败,error: gobog binary not found:意味着 go build 那步出错了,看 Actions 日志里 setup-go / go build 是不是 fail 了。多半是 gobog 仓库的 go.mod 里某个包失踪。
  • 新文章在首页死活不出现:检查 front-matter 是不是 draft: true 没去掉,或者 create_time 写错(gobog 用它排序)。