Skip to content

Commit 116a29a

Browse files
committed
Remake2
1 parent 219234c commit 116a29a

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

.github/workflows/build.yml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,79 @@
1+
# 工作流的名称
12
name: Deploy to GitHub Pages
23

4+
# 工作流的触发条件
35
on:
46
push:
7+
# 只在 lean4 分支有 push 时触发
8+
# 如果你的主要工作分支是 main,请把下面的 lean4 改成 main
59
branches:
6-
- lean4 # 如果你的工作分支不是 lean4,请修改成你的分支名,比如 main
7-
# 允许你从 Actions 页面手动运行
10+
- lean4
11+
# 允许你从 Actions 页面手动触发
812
workflow_dispatch:
913

10-
# 授予 Action 部署到 GitHub Pages 的权限
14+
# 授予工作流所需的权限
1115
permissions:
1216
contents: read
1317
pages: write
1418
id-token: write
1519

20+
# 定义工作流中的所有任务
1621
jobs:
22+
# 第一个任务:构建网站
1723
build:
1824
name: Build Website
1925
runs-on: ubuntu-latest
2026
steps:
27+
# 第 1 步:检出你的代码
2128
- name: Checkout your repository
2229
uses: actions/checkout@v4
2330

31+
# 第 2 步:安装 Python
2432
- name: Install Python
2533
uses: actions/setup-python@v5
2634
with:
2735
python-version: 3.11
2836

37+
# 第 3 步:设置缓存
38+
- name: Cache Pip dependencies
39+
uses: actions/cache@v4
40+
with:
41+
# 缓存 pip 的下载目录
42+
path: ~/.cache/pip
43+
# 基于操作系统和 requirements.txt 内容创建唯一 key
44+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
45+
# 如果没有完全匹配的缓存,使用一个通用的备用缓存
46+
restore-keys: |
47+
${{ runner.os }}-pip-
48+
49+
# 第 4 步:安装 bibtool
2950
- name: Install bibtool
3051
run: |
3152
sudo apt-get update --fix-missing
3253
sudo apt-get install bibtool -y
3354
55+
# 第 5 步:安装 Python 依赖(如果缓存命中,这步会飞快)
3456
- name: Install Python dependencies
3557
run: python -m pip install --upgrade pip -r requirements.txt
3658

59+
# 第 6 步:运行脚本来构建网站
3760
- name: Build the website
38-
# 我们现在直接运行 python 脚本来构建,而不是通过 deploy.sh
39-
# NODOWNLOAD=1 可以加快构建速度
4061
run: NODOWNLOAD=1 python make_site.py
4162

42-
- name: Upload the build artifact
43-
# 将构建好的网站文件(在 build/ 目录)打包,供下一个任务使用
63+
# 第 7 步:使用专用的 Action 来打包网站文件
64+
- name: Upload Pages artifact
4465
uses: actions/upload-artifact@v4
4566
with:
46-
name: github-pages
4767
path: ./build
4868

69+
# 第二个任务:部署网站
4970
deploy:
5071
name: Deploy to GitHub Pages
51-
# deploy 任务需要等待 build 任务成功完成
5272
needs: build
5373
runs-on: ubuntu-latest
5474
environment:
5575
name: github-pages
5676
url: ${{ steps.deployment.outputs.page_url }}
5777
steps:
5878
- name: Deploy from artifact
59-
# 这是官方的部署动作,它会自动处理所有事情
6079
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)