V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Reid
V2EX  ›  程序员

Hugo GitHub Action 部署没有 index.html

  •  
  •   Reid · 2022-06-06 16:05:17 +08:00 · 1372 次点击
    这是一个创建于 661 天前的主题,其中的信息可能已经有所发展或是发生改变。

    参考这篇文章部署了 Hugo ,https://www.fournoas.com/posts/deploy-hugo-site-using-github-actions/ 单独 Public 上传之后,https://reid00.github.io/ 可以正常访问, 但是 用 Github Action 之后发现个人主页变成了 index.xml 的形式 查看直接和 public 里面比,少了很多东西 各位彦祖,有知道怎么回事的吗?

    name: Deploy Hugo Site to Github Pages on Main Branch
    
    on:
      push:
        branches:
          - main
    
    jobs:
      build-deploy:
        runs-on: ubuntu-latest
        steps:
          - name: Check out repository code
            uses: actions/checkout@v3
            
          - name: Setup Hugo
            uses: peaceiris/actions-hugo@v2
            with:
              hugo-version: latest  # 这里的版本号要与你安装的版本号一致
              extended: true
    
          - name: Build
            run: hugo --minify
    
          - name: Deploy
            uses: peaceiris/actions-gh-pages@v3
            with:
              deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} # 这里的 ACTIONS_DEPLOY_KEY 则是上面设置 Private Key 的变量名
              external_repository: Reid00/Reid00.github.io # Pages 远程仓库 
              publish_dir: "./public"
              keep_files: false # remove existing files
              publish_branch: main  # deploying branch
              commit_message: ${{ github.event.head_commit.message }}
    
    
    
    hwdef
        1
    hwdef  
       2022-06-06 16:33:27 +08:00
    跟你执行的时候加了 --minify 参数有关吗
    istevenshen
        2
    istevenshen  
       2022-06-06 16:36:50 +08:00
    你指定 hugo 版本看看,如 hugo-version: '0.59.0',我也用的是 peaceiris/actions-gh-pages@v3 ,貌似一直都没什么问题
    Reid
        3
    Reid  
    OP
       2022-06-06 16:36:54 +08:00
    @hwdef 应该没关系,我刚刚更新了下试了下,不行,index.html 好多东西没有部署到 github pages 那个仓库
    istevenshen
        4
    istevenshen  
       2022-06-06 16:38:09 +08:00
    peaceiris/actions-hugo@v2
    istevenshen
        5
    istevenshen  
       2022-06-06 16:43:25 +08:00
    还有一个就是如果你使用了 themes ,记得要获取 submodule 主题,有时候 theme 目录空了也会导致个人主页变成了 index.xml
    Reid
        6
    Reid  
    OP
       2022-06-06 16:44:24 +08:00
    @istevenshen 也不太行,我之前试过,刚刚又更新了下 试了下。这个问题 搞了两天了...
    Reid
        7
    Reid  
    OP
       2022-06-06 16:50:54 +08:00
    @istevenshen public 了 source 仓库 https://github.com/Reid00/Reid00.github.io.source
    你这个方法,我刚刚加上了,我看看怎么解决这个 error
    istevenshen
        8
    istevenshen  
       2022-06-06 16:54:32 +08:00
    调整一下 jobs

    ```
    jobs:
    deploy:
    runs-on: ubuntu-20.04 # 在什么环境运行任务
    steps:
    - uses: actions/[email protected] # 引用 actions/checkout 这个 action ,与所在的 github 仓库同名
    with:
    submodules: true # Fetch Hugo themes (true OR recursive) 获取 submodule 主题
    fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod

    - name: Setup Hugo # 步骤名自取
    uses: peaceiris/actions-hugo@v2 # hugo 官方提供的 action ,用于在任务环境中获取 hugo
    with:
    hugo-version: '0.59.0' # 获取指定版本的 hugo
    ```
    Reid
        9
    Reid  
    OP
       2022-06-06 17:00:24 +08:00
    @istevenshen https://github.com/Reid00/Reid00.github.io.source/runs/6752751574?check_suite_focus=true
    调整了,但是报错了,
    ```shell
    [submodule "themes/PaperMod"]
    path = themes/PaperMod
    url = https://github.com/adityatelange/hugo-PaperMod.git

    ```
    gitmodules 里面是这个,不太知道怎么改
    jaredyam
        10
    jaredyam  
       2022-06-07 09:53:23 +08:00
    只能说你跟随的这篇博文有些过时,现在 Github Action 渲染的 public 基本都放在 github.io 仓库的一个独立分支,hugo 官方指引里有教程。
    OOLAOO
        11
    OOLAOO  
       2022-06-07 10:29:47 +08:00
    同问题, 我用 github actions 部署 hexo 博客打不开, 自己部署就能打开
    Reid
        12
    Reid  
    OP
       2022-06-07 11:36:33 +08:00
    @jaredyam 21 年的确实不是最新的了,但是我看 actions-gh-pages
    还是提供了这种方式的, 说明还是兼容的吧,就是不清楚目前的错误在哪里
    Reid
        13
    Reid  
    OP
       2022-06-07 11:38:38 +08:00
    @OOLAOO 我知道我这边的问题了,因为 public 里面又**.reid00.io 的.git 文件,删除之后发现好了
    tabris17
        14
    tabris17  
       2022-06-12 11:45:47 +08:00
    我是原文的作者,这个 action 脚本我现在还在用,没什么问题呀。我的 hugo 版本是 0.55 ,难道是我用的 hugo 版本比较老的关系?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1032 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 22:25 · PVG 06:25 · LAX 15:25 · JFK 18:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.