-
Notifications
You must be signed in to change notification settings - Fork 47
134 lines (112 loc) · 3.14 KB
/
CI.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# # 代码CI快速集成流水线,lint、fix、build
name: CI
# # 触发条件
on:
# 提PR到next分支触发CI
pull_request:
branches:
- next
push:
branches:
- next
# 手动触发部署
workflow_dispatch:
schedule:
- cron: '0 0 1 * *'
# 环境变量
env:
# 阿里云仓库信息
REGISTRY: registry.cn-hangzhou.aliyuncs.com
UserName: 142vip
jobs:
Base-Build:
name: 基础编译构建
runs-on: ubuntu-latest
# 主库且拉取PR时触发
if: github.repository == '142vip/408CSFamily' && github.event_name == 'pull_request'
permissions:
actions: read
pull-requests: read
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0
# 安装PNPM
- name: PNPM Install
uses: pnpm/action-setup@v4
with:
version: 9.6.0
# 安装Node环境
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.16.0
# # 缓存
cache: pnpm
# 下载依赖,并执行初始化脚本:钩子函数、思维导图构建
- name: Install Dependencies
run: |
./scripts/ci
- name: Code LintFix
run: |
pnpm lint
- name: Build Site
run: |
pnpm build
- name: Build Site With Proxy
run: |
pnpm build:proxy
Build-Docker-Image:
name: 构建Docker镜像
runs-on: ubuntu-latest
# 主库且tag更新时执行
if: github.repository == '142vip/408CSFamily' && startsWith(github.event.head_commit.message, 'chore(release):')
permissions:
actions: read
pull-requests: read
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login Docker
run: |
docker version
echo "-----------Docker Login-----------"
docker login \
--username=${{ env.UserName }} \
--password=${{ secrets.DOCKER_PASSWORD }} \
${{env.REGISTRY}}
# 安装PNPM
- name: PNPM Install
uses: pnpm/action-setup@v4
with:
version: 9.6.0
# 安装Node环境
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.16.0
# # 缓存
cache: pnpm
# 下载依赖,并执行初始化脚本:钩子函数、思维导图构建
- name: Install Dependencies
run: |
./scripts/ci
# # 构建,支持domain
# - name: Build To Dist
# run: |
# pnpm build
# 快速构建并推送
- name: Push Docker Image
run: |
./scripts/bundle