hexo(7)next新增deploy(One-Command Deployment)

hexo-deployer-git 是一个 Hexo 的插件,用于将生成的静态博客网站部署到 Git 仓库,通常用于部署到 GitHub Pages 或其他 Git 托管服务。

env

  • node-v22.10.0
  • joplin-hexo

doc

1.install hexojs/hexo-deployer-git

npm install hexo-deployer-git --save

2._config.yml新增配置

1
2
3
4
5
6
7
...
deploy:
type: git
# repo: http://ip:3000/mvpbang/web-station.git
repo: ssh://git@ip:10022/mvpbang/web-station.git
branch: [main]
# message: [message]

提前配置好ssh可信认证

支持多仓库deploy

deploy:
  type: git
  repo: 
    github:
      url: '[email protected]:yaohuiwu/yaohuiwu.github.io.git'
      branch: main

支持github token认证

deploy:
  - type: git
    repo: [email protected]:leimao/leimao.github.io.git
    branch: master
    # GitHub Fine-Grained Tokens
    token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    message: "Hexo & Icarus Deployment Updated: {{ now('YYYY-MM-DD HH:mm:ss') }}"
    ignore_hidden: false

3.deploy

hexo clean && hexo deploy
or
hexo clean && hexo generate && hexo deploy

过程信息:

➜  joplin-blog git:(main) ✗ hexo deploy
INFO  Validating config
INFO  Deploying: git
INFO  Clearing .deploy_git folder...
INFO  Copying files from public folder...
INFO  Copying files from extend dirs...
On branch master
nothing to commit, working tree clean
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: . Processing 1 references
remote: Processed 1 references in total
To ssh://ip:10022/mvpbang/web-station.git
 + 3ac7ecb...9e2d0c3 HEAD -> main (forced update)
branch 'master' set up to track 'ssh://git@ip:10022/mvpbang/web-station.git/main'.
INFO  Deploy done: git

查看deploy仓库是否同步过来public代码
a9fe7579bbbddf0e54506f8b381e3edf.png