Skip to content

Commit 7e01a77

Browse files
author
微信公众号:储凡
authored
Merge pull request #97 from mmdapl/docs/add
2 parents 18847cc + f38f513 commit 7e01a77

File tree

8 files changed

+416
-58
lines changed

8 files changed

+416
-58
lines changed

.github/workflows/CD.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ on:
1111
- next
1212
workflow_dispatch:
1313

14-
1514
# 环境变量
1615
env:
1716
## vercel
1817
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1918
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
2019

21-
2220
jobs:
2321
## 部署到Github-Pages
2422
deploy-github:

.github/workflows/CI.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
## 代码CI快速集成流水线,lint、fix、build
22
## 注意: 只在142vip/JavaScriptCollection时执行
33

4-
54
name: CI
65
## 触发条件
76
on:
@@ -75,7 +74,6 @@ jobs:
7574
run: |
7675
./scripts/bundle build_proxy
7776
78-
7977
Build-Docker-Image:
8078
name: "构建Docker镜像"
8179
## macos不支持docker的使用
@@ -108,7 +106,6 @@ jobs:
108106
--password=${{ secrets.DOCKER_PASSWORD }} \
109107
${{env.REGISTRY}}
110108
111-
112109
- name: Install Dependencies
113110
run: |
114111
./scripts/ci

docs/manuscripts/develop-skill/code-manager/CI-CD.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,158 @@ permalink: /manuscripts/develop-skill/code-manager/ci-cd.html
44
---
55

66
# 持续集成、持续交付
7+
8+
## 最佳实践
9+
10+
### 持续集成
11+
12+
```yaml
13+
## 代码CI快速集成流水线,lint、fix、build
14+
## 注意: 只在142vip/JavaScriptCollection时执行
15+
16+
name: CI
17+
## 触发条件
18+
on:
19+
# 提PR到next分支触发CI
20+
pull_request:
21+
branches:
22+
- next
23+
push:
24+
branches:
25+
- next
26+
27+
# 手动触发部署
28+
workflow_dispatch:
29+
30+
schedule:
31+
- cron: "0 0 1 * *"
32+
33+
jobs:
34+
Base-Build:
35+
name: "基础编译构建"
36+
runs-on: ubuntu-latest
37+
if: github.repository == '142vip/JavaScriptCollection' && github.event_name == 'pull_request'
38+
permissions:
39+
actions: read
40+
pull-requests: read
41+
42+
steps:
43+
- name: Checkout Code
44+
uses: actions/checkout@v4
45+
with:
46+
persist-credentials: false
47+
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
48+
fetch-depth: 0
49+
50+
## 安装PNPM
51+
- name: PNPM Install
52+
uses: pnpm/action-setup@v2
53+
with:
54+
version: 8
55+
56+
## 安装Node环境
57+
- name: Install Node.js
58+
uses: actions/setup-node@v3
59+
with:
60+
node-version: 18.18.0
61+
## 淘宝镜像加速
62+
registry-url: 'https://registry.npmmirror.com'
63+
## 缓存
64+
cache: 'pnpm'
65+
66+
## 下载依赖,并执行初始化脚本:钩子函数、思维导图构建
67+
- name: Install Dependencies
68+
run: |
69+
./scripts/ci
70+
71+
- name: Code LintFix
72+
run: |
73+
./scripts/lint
74+
75+
- name: Build Site
76+
run: |
77+
./scripts/bundle build
78+
79+
- name: Build Site With Proxy
80+
run: |
81+
./scripts/bundle build_proxy
82+
83+
```
84+
85+
### 持续交付
86+
87+
```yaml
88+
89+
## CD交付流水线
90+
## - 部署到Github Pages
91+
## - 部署到Vercel托管平台
92+
## - 发布新的Github Release
93+
## 参考资料:https://v2.vuepress.vuejs.org/zh/guide/deployment.html#github-pages
94+
95+
name: CD
96+
on:
97+
push:
98+
branches:
99+
- next
100+
workflow_dispatch:
101+
102+
jobs:
103+
## 版本发布
104+
release:
105+
name: "创建Github发布"
106+
runs-on: ubuntu-latest
107+
## 主库next且执行release更新时执行
108+
if: github.repository == '142vip/JavaScriptCollection' && startsWith(github.event.head_commit.message, 'chore(release):')
109+
110+
steps:
111+
- name: Checkout Code
112+
uses: actions/checkout@v4
113+
with:
114+
persist-credentials: false
115+
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
116+
fetch-depth: 0
117+
118+
### 打成压缩包
119+
- name: Create Zip Package
120+
run: |
121+
zip -r JavaScriptCollection.zip . \
122+
-x "node_modules/*" \
123+
-x ".git/*"
124+
125+
# 提取版本号
126+
- name: Get New Version Number
127+
id: releaseVersion
128+
run: |
129+
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
130+
131+
# 创建发布版本
132+
- name: Create New Release
133+
id: createRelease
134+
uses: actions/create-release@latest
135+
env:
136+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
137+
with:
138+
tag_name: v${{ steps.releaseVersion.outputs.version }}
139+
release_name: v${{ steps.releaseVersion.outputs.version }}
140+
body: |
141+
Release ${{ steps.releaseVersion.outputs.version }}
142+
143+
### Features
144+
145+
### Bug Fixes
146+
147+
## 更新资源
148+
- name: Upload Resource Assets
149+
uses: actions/upload-release-asset@latest
150+
env:
151+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152+
with:
153+
upload_url: ${{ steps.createRelease.outputs.upload_url }}
154+
asset_path: ./JavaScriptCollection.zip
155+
asset_name: JavaScriptCollection.zip
156+
asset_content_type: application/zip
157+
158+
159+
```
160+
161+
## 参考资料

0 commit comments

Comments
 (0)