55name : CI
66# # 触发条件
77on :
8+ # 提PR到next分支触发CI
89 pull_request :
910 branches :
10- - ' master'
11- - ' next'
12- - ' !pages/**'
11+ - next
1312 push :
1413 branches :
15- - master
1614 - next
15+
1716 # 手动触发部署
1817 workflow_dispatch :
1918
2726 UserName : 142vip
2827
2928jobs :
30- install-init :
31- name : " 流水线初始化 "
29+ Base-Build :
30+ name : " 基础编译构建 "
3231 runs-on : ubuntu-latest
33- if : github.repository == '142vip/JavaScriptCollection'
32+ if : github.repository == '142vip/JavaScriptCollection' && github.event_name == 'pull_request'
3433 permissions :
3534 actions : read
3635 pull-requests : read
@@ -43,51 +42,27 @@ jobs:
4342 # “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
4443 fetch-depth : 0
4544
46- # ## 依赖下载完成后,或执行思维导图编译
47- # - name: PNPM Install
48- # uses: pnpm/action-setup@v2
49- # with:
50- # version: 7
51- # run_install: |
52- # args: [--frozen-lockfile, --registry=https://registry.npmmirror.com]
53- # 安装Node环境
45+ # # 安装PNPM
46+ - name : PNPM Install
47+ uses : pnpm/action-setup@v2
48+ with :
49+ version : 8
50+
51+ # # 安装Node环境
5452 - name : Install Node.js
5553 uses : actions/setup-node@v3
5654 with :
5755 node-version : 18.18.0
5856 # # 淘宝镜像加速
5957 registry-url : ' https://registry.npmmirror.com'
58+ # # 缓存
59+ cache : ' pnpm'
6060
61+ # # 下载依赖,并执行初始化脚本:钩子函数、思维导图构建
6162 - name : Install Dependencies
6263 run : |
6364 ./scripts/ci
6465
65- - name : Cache Dependencies
66- uses : actions/cache@v3
67- with :
68- path : node_modules
69- key : ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
70-
71- Base-Build :
72- name : " 基础编译校验"
73- runs-on : ubuntu-latest
74- if : github.repository == '142vip/JavaScriptCollection'
75- needs :
76- - install-init
77- steps :
78- - name : Checkout Code
79- uses : actions/checkout@v4
80- with :
81- persist-credentials : false
82- # “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
83- fetch-depth : 0
84-
85- - name : Restore Dependencies From Cache
86- uses : actions/cache@v3
87- with :
88- path : node_modules
89- key : ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
90-
9166 - name : Code LintFix
9267 run : |
9368 ./scripts/lint --fix
@@ -100,12 +75,11 @@ jobs:
10075 run : |
10176 ./scripts/bundle build_proxy
10277
78+
10379 Build-Docker-Image :
10480 name : " 构建Docker镜像"
10581 # # macos不支持docker的使用
10682 runs-on : ubuntu-latest
107- needs :
108- - install-init
10983 # # 主库master、next且执行release更新时执行
11084 if : github.repository == '142vip/JavaScriptCollection' && startsWith(github.event.head_commit.message, 'chore(release):')
11185 permissions :
@@ -119,7 +93,10 @@ jobs:
11993 # “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
12094 fetch-depth : 0
12195
122- - name : Set up Docker
96+ - name : Set up QEMU
97+ uses : docker/setup-qemu-action@v3
98+
99+ - name : Set up Docker Buildx
123100 uses : docker/setup-buildx-action@v3
124101
125102 - name : Login Docker
@@ -131,19 +108,17 @@ jobs:
131108 --password=${{ secrets.DOCKER_PASSWORD }} \
132109 ${{env.REGISTRY}}
133110
134- - name : Restore Dependencies From Cache
135- uses : actions/cache@v3
136- with :
137- path : node_modules
138- key : ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
139111
112+ - name : Install Dependencies
113+ run : |
114+ ./scripts/ci
140115
141116 # # 构建,支持domain
142117 - name : Build To Dist
143118 run : |
144- ./scripts/bundle build_proxy
119+ ./scripts/bundle build
145120
146121 # # 快速构建并推送
147122 - name : Push Docker Image
148123 run : |
149- ./scripts/bundle image_faster
124+ ./scripts/bundle image_faster
0 commit comments