hewking.top

hewking's blog

View the Project on GitHub hewking/blog

构建基于 github ISSUE 的Blog

Author: hewking
Labels: blog
Created: 2024-12-01T05:02:20Z
Link and comments: https://github.com/hewking/blog/issues/9

构建 blog

1. 生成 github developer setting token

2. 创建 github actions

配置 github workflow/ main.yml, 执行action 如果无法访问创建 pull-request 需要在项目中进行设置

  1. 设置 secrets.GH_Token: setting -> Secrets and variables -> Actions -> new repository secret
    1. Repository secrets 访问: secrets.GH_Token
    2. Environment variables 访问: GH_Token
  2. github actions 设置 pull-request 权限: repo -> settings -> actions -> general -> read and write permissions (Workflow permissions)

设置 pull-request 权限

3. 配置部署 jekyll

  1. 设置 Pages
    1. repo -> settings -> pages -> source -> deploy from branch -> branch: main
    2. 如果已经设置过 CNNAME,部署后会自动部署到原域名
  2. 配置 _config.yml
# 基础配置
title: Your Blog Title
description: Your blog description
theme: jekyll-theme-minimal  # 或其他主题

# Jekyll 设置
markdown: kramdown
kramdown:
  input: GFM
  syntax_highlighter: rouge

# 可选:排除不需要处理的文件
exclude:
  - generate.py
  - README.md
  - .github/

这样设置后,每次 PR merge 到主分支,GitHub 会自动: 检测到 markdown 文件变化 用 Jekyll 构建站点 部署到 GitHub Pages 不需要额外的 workflow 文件,GitHub 会自动处理构建和部署。在 actions 中会生成 workflow: pages-build-deployment

参考资料