Skip to content

Commit ce7f125

Browse files
author
公众号:Rong姐姐好可爱
authored
Merge pull request #62 from mmdapl/perf/ci
perf: 流水线支持国内依赖源,规范CI/CD流程
2 parents 2766c2a + bc36957 commit ce7f125

File tree

2 files changed

+55
-67
lines changed

2 files changed

+55
-67
lines changed

.github/workflows/CD.yaml

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -23,60 +23,33 @@ env:
2323

2424

2525
jobs:
26-
install-init:
27-
name: "流水线初始化"
28-
runs-on: ubuntu-latest
26+
## 部署到Github-Pages
27+
deploy-github:
28+
name: "部署到Github-Pages"
29+
runs-on: macos-latest
2930

3031
steps:
3132
- name: Checkout Code
32-
uses: actions/checkout@v3
33+
uses: actions/checkout@v4
3334
with:
35+
persist-credentials: false
3436
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
3537
fetch-depth: 0
3638

39+
## 依赖下载完成后,或执行思维导图编译
3740
- name: PNPM Install
3841
uses: pnpm/action-setup@v2
3942
with:
4043
version: 7
41-
run_install: true
42-
43-
- name: Install Node.js
44-
uses: actions/setup-node@v3
45-
with:
46-
node-version: 16.20.2
47-
cache: 'pnpm'
48-
49-
- name: Cache Dependencies
50-
uses: actions/cache@v3
51-
with:
52-
path: |
53-
node_modules
54-
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
55-
56-
## 部署到Github-Pages
57-
deploy-github:
58-
name: "部署到Github-Pages"
59-
needs: install-init
60-
runs-on: ubuntu-latest
61-
62-
steps:
63-
- name: Checkout Code
64-
uses: actions/checkout@v3
65-
with:
66-
fetch-depth: 0
67-
68-
- name: Restore Dependencies From cache
69-
uses: actions/cache@v3
70-
with:
71-
path: |
72-
node_modules
73-
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
74-
44+
run_install: |
45+
args: [--frozen-lockfile, --registry=https://registry.npmmirror.com]
7546
7647
# 运行构建脚本
7748
- name: Build VuePress Site
78-
run: ./scripts/bundle build_proxy
49+
run: |
50+
./scripts/bundle build_proxy
7951
52+
## 部署到Github Pages
8053
- name: Deploy To GitHub Page
8154
uses: crazy-max/ghaction-github-pages@v3
8255
with:
@@ -89,7 +62,7 @@ jobs:
8962
# deploy-vercel:
9063
# name: "部署到Vercel平台"
9164
# needs: install-init
92-
# runs-on: ubuntu-latest
65+
# runs-on: macos-latest
9366
# if: github.repository == '142vip/JavaScriptCollection'
9467
# steps:
9568
# - name: Checkout Code
@@ -117,18 +90,17 @@ jobs:
11790
## 版本发布
11891
release:
11992
name: "创建Github发布"
120-
runs-on: ubuntu-latest
121-
needs: install-init
93+
runs-on: macos-latest
12294
## 主库master、next且执行release更新时执行
12395
if: github.repository == '142vip/JavaScriptCollection' && startsWith(github.event.head_commit.message, 'chore(release):')
12496

12597
steps:
126-
- name: Restore Dependencies From cache
127-
uses: actions/cache@v3
98+
- name: Checkout Code
99+
uses: actions/checkout@v4
128100
with:
129-
path: |
130-
node_modules
131-
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
101+
persist-credentials: false
102+
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
103+
fetch-depth: 0
132104

133105
### 打成压缩包
134106
- name: Create Zip Package
@@ -172,7 +144,7 @@ jobs:
172144
# Deploy-ESC:
173145
# name: "部署到ESC服务器"
174146
# needs: install-init
175-
# runs-on: ubuntu-latest
147+
# runs-on: macos-latest
176148
# ## 主库master、next且执行release更新时执行
177149
# if: github.repository == '142vip/JavaScriptCollection' && startsWith(github.event.head_commit.message, 'chore(release):')
178150
#

.github/workflows/CI.yaml

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,52 @@ on:
2222
jobs:
2323
install-init:
2424
name: "流水线初始化"
25-
runs-on: ubuntu-latest
25+
runs-on: macos-latest
2626
permissions:
2727
actions: read
2828
pull-requests: read
2929

3030
steps:
31-
- name: checkout code
32-
uses: actions/checkout@v3
31+
- name: Checkout Code
32+
uses: actions/checkout@v4
3333
with:
34+
persist-credentials: false
3435
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
3536
fetch-depth: 0
3637

38+
## 依赖下载完成后,或执行思维导图编译
3739
- name: PNPM Install
3840
uses: pnpm/action-setup@v2
3941
with:
4042
version: 7
41-
run_install: true
43+
run_install: |
44+
args: [--frozen-lockfile, --registry=https://registry.npmmirror.com]
4245
43-
- name: Install Node.js
44-
uses: actions/setup-node@v3
45-
with:
46-
node-version: 16.20.2
47-
cache: 'pnpm'
46+
# - name: Install Node.js
47+
# uses: actions/setup-node@v3
48+
# with:
49+
# node-version: 18.18.0
50+
# ## 淘宝镜像加速
51+
# registry-url: 'https://registry.npmmirror.com'
52+
# cache: 'pnpm'
4853

4954
- name: Cache Dependencies
5055
uses: actions/cache@v3
5156
with:
5257
path: node_modules
5358
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
59+
5460
Base-Build:
5561
name: "基础编译构建"
56-
runs-on: ubuntu-latest
57-
needs: install-init
62+
runs-on: macos-latest
63+
needs:
64+
- install-init
5865
steps:
5966
- name: Checkout Code
60-
uses: actions/checkout@v3
67+
uses: actions/checkout@v4
6168
with:
69+
persist-credentials: false
70+
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
6271
fetch-depth: 0
6372

6473
- name: Restore Dependencies From Cache
@@ -68,18 +77,22 @@ jobs:
6877
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
6978

7079
- name: Code LintFix
71-
run: ./scripts/lint --fix
80+
run: |
81+
./scripts/lint --fix
7282
7383
- name: Build Site
74-
run: ./scripts/bundle build
84+
run: |
85+
./scripts/bundle build
7586
7687
- name: Build Site With Proxy
77-
run: ./scripts/bundle build_proxy
88+
run: |
89+
./scripts/bundle build_proxy
7890
7991
Build-Docker-Image:
8092
name: "构建Docker镜像"
81-
runs-on: ubuntu-latest
82-
needs: install-init
93+
runs-on: macos-latest
94+
needs:
95+
- install-init
8396
## 主库master、next且执行release更新时执行
8497
if: github.repository == '142vip/JavaScriptCollection' && startsWith(github.event.head_commit.message, 'chore(release):')
8598
permissions:
@@ -111,7 +124,10 @@ jobs:
111124

112125
## 构建,支持domain
113126
- name: Build To Dist
114-
run: ./scripts/bundle build_proxy
127+
run: |
128+
./scripts/bundle build_proxy
115129
130+
## 快速构建并推送
116131
- name: Push Docker Image
117-
run: ./scripts/bundle image_faster
132+
run: |
133+
./scripts/bundle image_faster

0 commit comments

Comments
 (0)