Skip to content

使用 GitHub Actions 部署 Hugo 博客到 GitHub Pages #90

@reuixiy

Description

@reuixiy
  1. 复制 .github 文件夹

  2. 修改 .github/workflows/build.ymlGIT_REPOGIT_BRANCH

  3. 生成 id_rsaid_rsa.pub

    ssh-keygen -t rsa -b 4096 -C "reuixiy@users.noreply.github.com"

    1. id_rsa 的内容复制,添加到源码仓库的 Settings > Secrets > New secret,Name 必须为 GIT_DEPLOY_KEY
    2. id_ras_pub 的内容复制,添加到部署仓库的 Settings > Deploy keys > Add deploy key,Title 随便,可以为 GitHub Pages,务必勾选 Allow write access。
    3. 如果源码仓库和部署仓库为同一仓库,则在同一仓库配置。
  4. static 文件夹下添加一个 CNAME 文件,里面加上自己的域名,如 io-oi.me
    https://docs.github.com/en/github/working-with-github-pages/managing-a-custom-domain-for-your-github-pages-site#configuring-an-apex-domain

  5. git add & git commit & git push

  6. 前往部署仓库,Settings > Options > GitHub Pages,将 Source 中的 Branch 选择为 GIT_BRANCH

  7. 前往域名提供商,修改 DNS 记录,减少第三方 #87 (comment)

  8. 返回部署仓库,将 Enforce HTTPS 勾选

其它:可修改 README.md,加上官方提供的 badge:[![Built on GitHub](https://github.com/reuixiy/io-oi.me/workflows/build/badge.svg)](https://github.com/reuixiy/io-oi.me/actions)

脚注:对于 GitHub Pages,一个是用户的 GitHub Pages,仓库名必须为 <user>.github.io;一个项目的 GitHub Pages,将会部署到 http(s)://<user>.github.io/<repository>https://docs.github.com/en/github/working-with-github-pages/about-github-pages#types-of-github-pages-sites

Metadata

Metadata

Assignees

No one assigned

    Labels

    Todo待写的新文章

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions