44 branches :
55 - main
66 - master
7+ # 纯文档改动不触发部署
78 paths-ignore :
89 - .gitignore
910 - README.md
1011 - LICENSE
1112
12- # Allows you to run this workflow manually from the Actions tab
13+ # 允许在 Actions 页面手动点按钮触发
1314 workflow_dispatch :
1415
1516permissions :
1617 contents : read
17- pages : write
18- id-token : write
18+ pages : write # 发布到 GitHub Pages 必须
19+ id-token : write # actions/deploy-pages 的 OIDC 身份验证必须
1920
20- # Allow one concurrent deployment
21+ # 同一时间只跑一个部署;连续 push 时取消旧的,只跑最新的
2122concurrency :
2223 group : " pages"
2324 cancel-in-progress : true
@@ -30,29 +31,41 @@ jobs:
3031 - name : Checkout
3132 uses : actions/checkout@v4
3233 with :
34+ # 完整 git 历史,不做浅克隆
35+ # _plugins/posts-lastmod-hook.rb 需要读历史来注入 last_modified_at
3336 fetch-depth : 0
3437 # submodules: true
3538 # If using the 'assets' git submodule from Chirpy Starter, uncomment above
3639 # (See: https://github.com/cotes2020/chirpy-starter/tree/main/assets)
3740
41+ # 配置 GitHub Pages 环境,主要输出 base_path
42+ # 如果站点不在根路径(如 /repo-name/),后续构建需要用到
3843 - name : Setup Pages
3944 id : pages
4045 uses : actions/configure-pages@v3
4146
47+ # 安装 Ruby;bundler-cache: true 自动跑 bundle install 并缓存 gems
48+ # Gemfile.lock 不变时直接用缓存,加速构建
4249 - name : Setup Ruby
4350 uses : ruby/setup-ruby@v1
4451 with :
45- ruby-version : 3.2.2
52+ ruby-version : 4.0
4653 bundler-cache : true
4754
55+ # 构建前预处理:把 tags/categories 转小写,清理 TOC
4856 - name : puppylpg's scripts
4957 run : bin/lower_tag.sh && bin/clean_toc.sh
5058
59+ # 核心构建步骤,用 Gemfile.lock 里的 Jekyll(目前 4.4.1)生成静态文件
60+ # JEKYLL_ENV=production 开启 analytics、comments 等生产环境功能
5161 - name : Build site
5262 run : bundle exec jekyll b -d "_site${{ steps.pages.outputs.base_path }}"
5363 env :
5464 JEKYLL_ENV : " production"
5565
66+ # 检查生成的 HTML:链接有效性、图片存在等;失败则阻止部署
67+ # --disable-external: 跳过外链检查(太慢)
68+ # --ignore-files "/tutorials/": tutorials 有残留坏链,清理前先跳过
5669 - name : Test site
5770 run : |
5871 bundle exec htmlproofer _site \
6174 \-\-ignore-files "/tutorials/" \
6275 \-\-ignore-urls "/^http:\/\/127.0.0.1/,/^http:\/\/0.0.0.0/,/^http:\/\/localhost/"
6376
77+ # 把 _site/ 打包上传为 artifact,供 deploy job 使用
78+ # 两个 job 不共享文件系统,只能通过 artifact 传递产物
6479 - name : Upload site artifact
6580 uses : actions/upload-pages-artifact@v3
6681 with :
7186 name : github-pages
7287 url : ${{ steps.deployment.outputs.page_url }}
7388 runs-on : ubuntu-latest
74- needs : build
89+ needs : build # build job 成功才执行,失败则跳过
7590 steps :
91+ # 把 build job 上传的静态文件发布到 GitHub Pages
92+ # GitHub Pages 在这里只做托管,Jekyll 构建早已在 build job 完成
7693 - name : Deploy to GitHub Pages
7794 id : deployment
7895 uses : actions/deploy-pages@v4
0 commit comments