Github 通过操作从私有存储库部署页面

问题描述 投票:0回答:1

我正在尝试按照本教程从私有源代码库获取公共github页面,该页面使用来自

ssh-keygen -t rsa -b 4096 -C "$(git config user.email)" -f deployment -N ""

的PUBLIC和PRIVATE关键变量

我的设置与链接中描述的相同,但我无法理解实际上不起作用的内容。

通过使用相同的 GitHub 操作

name: Github Pages

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.83.0'

      - name: Build
        run: hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          deploy_key: ${{ secrets.PRIVATE_KEY }}
          external_repository: <username/username.github.io>
          publish_dir: ./public

它无法构建,因为

Error: Unable to locate config file or config directory. Perhaps you need to create a new site.Run `hugo help new` for details.

然后我将整个工作流程替换为 [Hugo] (https://gohugo.io/hosting-and-deployment/hosting-on-github/) 建议的工作流程,这是更新的。然后我添加到最后的部署操作

   steps:
       - name: Deploy to GitHub Pages
         id: deployment
         uses: actions/deploy-pages@v2
         with:
           deploy_key: ${{ secrets.PRIVATE_KEY }}
           external_repository: <username/username.github.io>
           publish_dir: ./public

失败了

Error: Get Pages site failed. Please verify that the repository has Pages enabled and configured to build using GitHub Actions, or consider exploring the `enablement` parameter for this action. Error: HttpError: Not Found

我已经设置了部署密钥和私钥,并且网址似乎是正确的,并且在公共存储库中我对页面进行了以下设置

从分支、brain main 和 /root 部署。在上一个教程中,他们提到了 gh-page 源,但它不可用(除了 main 之外我没有其他东西)。是不是应该多开一个分行?

抱歉帖子太长,感谢您的帮助!

git github-actions github-pages hugo building-github-actions
1个回答
0
投票

我正在寻找类似的 GH 操作工作流程,允许从私有存储库部署到公共存储库。我发现这篇文章,它的工作流程与你的非常接近。该工作流程非常适合我的目的。我将其包含在以下内容中。我能看到的唯一区别是

Deploy
部分。就我而言,有一个
publish_branch
变量,尽管这可能与问题没有直接关系。

另一方面,根据第一条错误消息,也许您想检查源存储库的根目录中是否定义了

config.yml
config.toml
。还要记得将
.nojekyll
放在
gh-pages
分支的根部。

name: github pages

on:
  push:
    branches:
      - main  # Set a branch to deploy
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod

      - 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.PRIVATE_KEY }}
          external_repository: your_github_username/your_github_username.github.io
          publish_branch: gh-pages
          publish_dir: ./public
© www.soinside.com 2019 - 2024. All rights reserved.