Skip to content

Commit 25b093e

Browse files
lujun9972claude
andcommitted
blog: 精简用GitHub Actions自动构建EGO博客
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dbbd3e4 commit 25b093e

1 file changed

Lines changed: 5 additions & 27 deletions

File tree

Emacs之怒/用GitHub Actions自动构建EGO博客.org

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@
4747
:store-dir ,(or (getenv "STORE_DIR") "~/web")))
4848
#+end_src
4949

50-
同时删除了已废弃的 CSDN 和头条发布代码(对应的包在本机也不存在了),精简了脚本。
5150

5251
** 第二步:编写 GitHub Actions Workflow
5352

54-
最终的 workflow 文件 ~.github/workflows/github-action.yml~:
53+
最终的 workflow 文件 ~.github/workflows/github-action.yml~
5554

5655
#+begin_src yaml
5756
name: 提交 habitica 任务 + 构建博客
@@ -149,27 +148,7 @@ Cannot open load file: No such file or directory, ht
149148

150149
解决:在 ~package-install~ 列表中加上 ~ht~ 和 ~dash~。
151150

152-
*** 坑2:本地包在 CI 中不存在
153-
154-
~toutiao~ 和 ~csdn-publish~ 是我本地的自定义包,不在任何包管理器上。CI 里根本没有:
155-
156-
#+begin_quote
157-
Cannot open load file: No such file or directory, toutiao
158-
#+end_quote
159-
160-
解决:用 ~(require 'toutiao nil t)~ 的 ~noerror~ 模式,找不到就静默跳过。后来发现本机上这两个包也早已不用了,干脆直接删除了相关代码。
161-
162-
*** 坑3:括号不匹配
163-
164-
删代码时一不小心把 ~let*~ 的关闭括号也删了,导致 Emacs 解析到文件末尾时报错:
165-
166-
#+begin_quote
167-
End of file during parsing: auto_publish.el
168-
#+end_quote
169-
170-
解决:补回括号,并用 ~emacs --batch --eval '(check-parens)'~ 验证。
171-
172-
*** 坑4:EGO 内部 git commit 缺少身份
151+
*** 坑2:EGO 内部 git commit 缺少身份
173152

174153
EGO 构建完后会用 ~vc-git-commit~ 提交 store-dir 的变更,但 store-dir 里没配 git user:
175154

@@ -179,7 +158,7 @@ Failed (status 128): git --no-pager commit -m Update published html files...
179158

180159
解决:clone master 分支后立即配置 ~git config user.name/email~。
181160

182-
*** 坑5:EGO 的 stash/pop 在 CI 中失败
161+
*** 坑3:EGO 的 stash/pop 在 CI 中失败
183162

184163
这是最难搞的一个。EGO 检测到 repo 有未提交变更时,会先 ~git stash~,构建完成后再 ~git stash pop~。但在 CI 中 stash pop 总是失败:
185164

@@ -203,8 +182,7 @@ Failed (status 1): git --no-pager stash pop -q 0 .
203182
整个折腾过程的核心就是让 ~auto_publish.el~ 在 CI 环境和本地环境都能正常运行。关键改动:
204183

205184
1. 路径可配置化(环境变量 + 默认值)
206-
2. 删除废弃的第三方发布代码
207-
3. 补全缺失的依赖包
208-
4. 用 ~checkin-all~ 绕过 stash/pop 兼容性问题
185+
2. 补全缺失的依赖包
186+
3. 用 ~checkin-all~ 绕过 stash/pop 兼容性问题
209187

210188
虽然中间踩了不少坑,但最终效果还是很满意的——以后 push 博客源文件就能自动构建发布,再也不用手动跑 ~auto_publish.el~ 了。

0 commit comments

Comments
 (0)