Hugo GitHub Action 部署没有 index.html

2022-06-06 16:05:17 +08:00
 Reid

参考这篇文章部署了 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 }}


1418 次点击
所在节点    程序员
14 条回复
hwdef
2022-06-06 16:33:27 +08:00
跟你执行的时候加了 --minify 参数有关吗
istevenshen
2022-06-06 16:36:50 +08:00
你指定 hugo 版本看看,如 hugo-version: '0.59.0',我也用的是 peaceiris/actions-gh-pages@v3 ,貌似一直都没什么问题
Reid
2022-06-06 16:36:54 +08:00
@hwdef 应该没关系,我刚刚更新了下试了下,不行,index.html 好多东西没有部署到 github pages 那个仓库
istevenshen
2022-06-06 16:38:09 +08:00
peaceiris/actions-hugo@v2
istevenshen
2022-06-06 16:43:25 +08:00
还有一个就是如果你使用了 themes ,记得要获取 submodule 主题,有时候 theme 目录空了也会导致个人主页变成了 index.xml
Reid
2022-06-06 16:44:24 +08:00
@istevenshen 也不太行,我之前试过,刚刚又更新了下 试了下。这个问题 搞了两天了...
Reid
2022-06-06 16:50:54 +08:00
@istevenshen public 了 source 仓库 https://github.com/Reid00/Reid00.github.io.source
你这个方法,我刚刚加上了,我看看怎么解决这个 error
istevenshen
2022-06-06 16:54:32 +08:00
调整一下 jobs

```
jobs:
deploy:
runs-on: ubuntu-20.04 # 在什么环境运行任务
steps:
- uses: actions/checkout@v2.3.5 # 引用 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
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
2022-06-07 09:53:23 +08:00
只能说你跟随的这篇博文有些过时,现在 Github Action 渲染的 public 基本都放在 github.io 仓库的一个独立分支,hugo 官方指引里有教程。
OOLAOO
2022-06-07 10:29:47 +08:00
同问题, 我用 github actions 部署 hexo 博客打不开, 自己部署就能打开
Reid
2022-06-07 11:36:33 +08:00
@jaredyam 21 年的确实不是最新的了,但是我看 actions-gh-pages
还是提供了这种方式的, 说明还是兼容的吧,就是不清楚目前的错误在哪里
Reid
2022-06-07 11:38:38 +08:00
@OOLAOO 我知道我这边的问题了,因为 public 里面又**.reid00.io 的.git 文件,删除之后发现好了
tabris17
2022-06-12 11:45:47 +08:00
我是原文的作者,这个 action 脚本我现在还在用,没什么问题呀。我的 hugo 版本是 0.55 ,难道是我用的 hugo 版本比较老的关系?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/857611

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX