mirror of
https://github.com/142vip/408CSFamily.git
synced 2026-02-03 02:23:38 +08:00
144 lines
3.7 KiB
YAML
144 lines
3.7 KiB
YAML
## 代码CI快速集成流水线,lint、fix、build
|
||
|
||
name: CI
|
||
## 触发条件
|
||
on:
|
||
# 提PR到next分支触发CI
|
||
pull_request:
|
||
branches:
|
||
- next
|
||
push:
|
||
branches:
|
||
- master
|
||
- next
|
||
# 手动触发部署
|
||
workflow_dispatch:
|
||
|
||
schedule:
|
||
- cron: "0 0 1 * *"
|
||
|
||
jobs:
|
||
install-init:
|
||
name: "依赖安装初始化"
|
||
runs-on: macos-latest
|
||
permissions:
|
||
actions: read
|
||
pull-requests: read
|
||
|
||
steps:
|
||
- name: Checkout Code
|
||
uses: actions/checkout@v4
|
||
with:
|
||
persist-credentials: false
|
||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||
fetch-depth: 0
|
||
|
||
# ## 依赖下载完成后,或执行思维导图编译
|
||
# - name: PNPM Install
|
||
# uses: pnpm/action-setup@v2
|
||
# with:
|
||
# version: 7
|
||
# run_install: |
|
||
# args: [--frozen-lockfile, --registry=https://registry.npmmirror.com]
|
||
# 安装Node环境
|
||
- name: Install Node.js
|
||
uses: actions/setup-node@v3
|
||
with:
|
||
node-version: 18.18.0
|
||
## 淘宝镜像加速
|
||
registry-url: 'https://registry.npmmirror.com'
|
||
|
||
- name: Install Dependencies
|
||
run: ./scripts/ci
|
||
|
||
- name: Cache Dependencies
|
||
uses: actions/cache@v3
|
||
with:
|
||
path: node_modules
|
||
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||
|
||
Base-Build:
|
||
name: "基础编译构建"
|
||
runs-on: macos-latest
|
||
needs:
|
||
- install-init
|
||
steps:
|
||
- name: Checkout Code
|
||
uses: actions/checkout@v4
|
||
with:
|
||
persist-credentials: false
|
||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||
fetch-depth: 0
|
||
|
||
- name: Restore Dependencies From Cache
|
||
uses: actions/cache@v3
|
||
with:
|
||
path: node_modules
|
||
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||
|
||
- name: Code LintFix
|
||
run: |
|
||
./scripts/lint --fix
|
||
|
||
## 支持思维导图转化
|
||
- name: Build Mark-Map
|
||
run: |
|
||
./scripts/mark-map
|
||
|
||
- name: Build Site
|
||
run: |
|
||
./scripts/bundle build
|
||
|
||
- name: Build Site With Proxy
|
||
run: |
|
||
./scripts/bundle build_proxy
|
||
|
||
Build-Docker-Image:
|
||
name: "构建Docker镜像"
|
||
runs-on: macos-latest
|
||
needs:
|
||
- install-init
|
||
## 主库且tag更新时执行
|
||
if: github.repository == '142vip/408CSFamily' && startsWith(github.ref, 'refs/tags/v')
|
||
permissions:
|
||
actions: read
|
||
pull-requests: read
|
||
|
||
steps:
|
||
- name: Checkout Code
|
||
uses: actions/checkout@v4
|
||
with:
|
||
persist-credentials: false
|
||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||
fetch-depth: 0
|
||
|
||
- name: Login Docker
|
||
run: |
|
||
docker version
|
||
echo "-----------Docker Login-----------"
|
||
docker login \
|
||
--username=${{ env.UserName }} \
|
||
--password=${{ secrets.DOCKER_PASSWORD }} \
|
||
${{env.REGISTRY}}
|
||
|
||
- name: Restore Dependencies From Cache
|
||
uses: actions/cache@v3
|
||
with:
|
||
path: node_modules
|
||
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||
|
||
## 支持思维导图转化
|
||
- name: Build Mark-Map
|
||
run: |
|
||
./scripts/mark-map
|
||
|
||
## 构建,支持domain
|
||
- name: Build To Dist
|
||
run: |
|
||
./scripts/bundle build_proxy
|
||
|
||
## 快速构建并推送
|
||
- name: Push Docker Image
|
||
run: |
|
||
./scripts/bundle image_faster
|