mythsman / hexo-douban

:cd: a Hexo plugin that helps you generate content for Douban books, movies, music, and games.
MIT License
455 stars 57 forks source link

Github Action 自动部署时,提示 hexo douban 不是命令 #133

Closed kuole-o closed 1 year ago

kuole-o commented 1 year ago

目前本地生成、预览都没有问题。部署后,页面没有豆瓣电影的数据:查看我的电影页面

已确认 hexo / node ,本地和 github action 构建时,都是相同的版本。提示 hexo douban 不是命令,也是我查看 github action 日志发现的。

    "hexo": "^6.3.0",
    "hexo-douban": "^2.2.1",
    "hexo-server": "^3.0.0",
    "hexo-theme-butterfly": "^4.8.5",

"node": "18.15"

已经配置了builtin: true,但是构建后,确实没有数据。我又自己再 github action 的流程配置中,hexo generate 下新增了 hexo douban 命令,于是收到了上述的错误:help, you can use 'hexo help [command]' for the detailed information

github action 流程配置部分为:

    - name: Build Hexo
      run: |
        hexo clean
        hexo generate
        hexo douban
        gulp

github action log

Run hexo clean
  hexo clean
  hexo generate
  hexo douban
  gulp

shell: /usr/bin/bash -e {0}

INFO  Validating config
INFO  
  ===================================================================
      #####  #    # ##### ##### ###### #####  ###### #      #   #
      #    # #    #   #     #   #      #    # #      #       # #
      #####  #    #   #     #   #####  #    # #####  #        #
      #    # #    #   #     #   #      #####  #      #        #
      #    # #    #   #     #   #      #   #  #      #        #
      #####   ####    #     #   ###### #    # #      ######   #
                            4.8.1
  ===================================================================
INFO  Validating config
INFO  
  ===================================================================
      #####  #    # ##### ##### ###### #####  ###### #      #   #
      #    # #    #   #     #   #      #    # #      #       # #
      #####  #    #   #     #   #####  #    # #####  #        #
      #    # #    #   #     #   #      #####  #      #        #
      #    # #    #   #     #   #      #   #  #      #        #
      #####   ####    #     #   ###### #    # #      ######   #
                            4.8.1
  ===================================================================
INFO  Start processing

**这里有一些 hexo g 渲染的内容,被我省略了**

INFO  Validating config
INFO  
  ===================================================================
      #####  #    # ##### ##### ###### #####  ###### #      #   #
      #    # #    #   #     #   #      #    # #      #       # #
      #####  #    #   #     #   #####  #    # #####  #        #
      #    # #    #   #     #   #      #####  #      #        #
      #    # #    #   #     #   #      #   #  #      #        #
      #####   ####    #     #   ###### #    # #      ######   #
                            4.8.1
  ===================================================================
Usage: hexo <command>

Commands:
  clean     Remove generated files and cache.
  config    Get or set configurations.
  deploy    Deploy your website.
  generate  Generate static files.
  help      Get help on a command.
  init      Create a new Hexo folder.
  list      List the information of the site
  migrate   Migrate your site from other system to Hexo.
  new       Create a new post.
  publish   Moves a draft post from _drafts to _posts folder.
  render    Render files with renderer plugins.
  server    Start the server.
  version   Display version information.

Global Options:
  --config  Specify config file instead of using _config.yml
  --cwd     Specify the CWD
  --debug   Display all verbose messages in the terminal
  --draft   Display draft posts
  --safe    Disable all plugins and scripts
  --silent  Hide output on console

help, you can use 'hexo help [command]' for the detailed information
or you can check the docs: http://hexo.io/docs/

**可以看到,从这部分开始,hexo douban 执行失败,跳过执行下面的 gulp 命令了**
[15:33:25] Using gulpfile ~/work/blog-butterfly/blog-butterfly/gulpfile.js
[15:33:25] Starting 'default'...
[15:33:25] Starting 'compress'...
[15:33:25] Starting 'minify-css'...
[15:33:25] Starting 'minify-html'...
[15:33:25] Starting 'mini-font'...
[15:33:25] Starting 'generate-service-worker'...
[15:33:25] Finished 'compress' after 12 ms
[15:33:25] Finished 'minify-css' after 89 ms
[15:33:25] Finished 'minify-html' after 89 ms
[15:33:25] Finished 'mini-font' after 89 ms
[15:33:26] Finished 'generate-service-worker' after 875 ms
[15:33:26] Finished 'default' after 878 ms
[15:34:06] gulp-fontmin: Minified 0 fonts

疑惑

hexo-douban 是如何将 hexo douban 命令插入的?假如不能正常识别运行 hexo douban,我还可以用其他什么命令来触发 hexo douban 的渲染流程吗?求解

kuole-o commented 1 year ago
image
mythsman commented 1 year ago

hexo 命令嵌入用的是这个 API (https://hexo.io/api/console)。 怀疑你是不是没有 npm install 全?

kuole-o commented 1 year ago

hexo 命令嵌入用的是这个 API (https://hexo.io/api/console)。 怀疑你是不是没有 npm install 全?

不应该啊,本地直接 npm install 安装的,GitHub action 里也是这样。而且,本地已经正常预览了的

mythsman commented 1 year ago

本地能正常的话,那应该就是你 github action 配置的有问题。。。这块我没配过,不太清楚。。。

mythsman commented 1 year ago

如果集成起来实在有问题,也可以试试 idouban ,直接引 js 渲染。

kuole-o commented 1 year ago

问题已解决,原因我也不知道…………我只是在 GitHub action 配置文件里,被 node 和 hexo 安装顺序调整了一下,就正常了…………好神奇。调整后内容如下:

    - name: Install Node.js 18
      uses: actions/setup-node@v3
      with:
        node-version: 18.15

    - name: Install Hexo
      run: |
        export TZ='Asia/Shanghai'
        npm install hexo-cli -g
        hexo -v