为了提升博客的 SEO 优化效果,我尝试将 jsdelivr CDN 本地化,以解决可能存在的加载速度问题。然而,在执行 Hexo d 命令部署博客时,却遭遇了令人困扰的 “Spawn failed” 错误,导致部署中断。本文将详细记录我如何一步步排查并最终解决这一问题的过程,希望能为遇到类似困境的 Hexo 用户提供有价值的参考和帮助。

问题分析和解决

本地化修改完成后提交代码显示如下报错:

Snipaste_2025-03-31_20-53-58

看着是远端断开了连接然后进行了以下尝试都以失败告终。

  1. 重启科学上网工具 & 命令行科学上网
  2. 删除 .deploy_git 文件
  3. 修改 git postBuffer
  4. 进入 .deploy_git 强推

想着可能还是网络问题,那我用 Github Actions 自动化应该没问题了吧。依然报错,具体错误如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
remote: error: GH013: Repository rule violations found for refs/heads/master.        
remote:
remote: - GITHUB PUSH PROTECTION
remote: —————————————————————————————————————————
remote: Resolve the following violations before pushing again
remote:
remote: - Push cannot contain secrets
remote:
remote:
remote: (?) Learn how to resolve a blocked push
remote: https://docs.github.com/code-security/secret-scanning/working-with-secret-scanning-and-push-protection/working-with-push-protection-from-the-command-line#resolving-a-blocked-push
remote:
remote: (?) This repository does not have Secret Scanning enabled, but is eligible. Enable Secret Scanning to view and manage detected secrets.
remote: Visit the repository settings page, https://github.com/Norvon/norvon.github.io/settings/security_analysis
remote:
remote:
remote: —— Tencent Cloud Secret ID ———————————————————————————
remote: locations:
remote: - commit: cfe83ee85b30f513ef5002d23fdd684629fb330c
remote: path: pluginsSrc/twikoo/dist/twikoo.all.min.js:2
remote:
remote: (?) To push, remove secret from commit(s) or follow this URL to allow the secret.
remote: https://github.com/Norvon/norvon.github.io/security/secret-scanning/unblock-secret/2v57KmGpz07dbIL6GwazSomPnBd
remote:
remote:
remote:
To https://github.com/Norvon/norvon.github.io.git
! [remote rejected] HEAD -> master (push declined due to repository rule violations)
error: failed to push some refs to 'https://github.com/Norvon/norvon.github.io.git'
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Error: Spawn failed
at ChildProcess.<anonymous> (/home/runner/work/MyBlogCode/MyBlogCode/node_modules/hexo-deployer-git/node_modules/hexo-util/lib/spawn.js:51:21)
at ChildProcess.emit (node:events:524:28)
at ChildProcess._handle.onexit (node:internal/child_process:293:12)
Error: Process completed with exit code 2.

从上面的错误可以看到是 pluginsSrc/twikoo/dist/twikoo.all.min.js:2 里面包含了 Tencent Cloud Secret ID Github 安全检测到了,然后把推送请求拦截了。

我看了下 pluginsSrc/twikoo/dist/twikoo.all.min.js:2 里面的报错的那个只是个注释。我们手动按允许这个推送就行了。具体参考 twikoo/issues 就行了。

总结

GitHub 的安全扫描功能可以有效防止敏感信息泄露,但有时也会出现误报。在遇到此类问题时,请务必仔细检查错误信息,并根据实际情况采取相应的解决方案。