Skip to content

Commit

Permalink
feat: 优化流水线缓存 (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmdapl authored Oct 10, 2023
1 parent 384a752 commit dadfea4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 84 deletions.
90 changes: 18 additions & 72 deletions .github/workflows/CD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,47 +19,9 @@ env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

jobs:
install-init:
name: "依赖安装初始化"
runs-on: macos-latest

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

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18.18.0
## 淘宝镜像加速
registry-url: 'https://registry.npmmirror.com'
cache: 'pnpm'

- name: Install Dependencies
run: |
pnpm i --frozen-lockfile --registry https://registry.npmmirror.com
- name: Cache Dependencies
uses: actions/cache@v3
with:
path: |
node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}

## 部署到Github-Pages
deploy-github:
name: "部署到Github-Pages"
needs:
- install-init
runs-on: macos-latest

steps:
Expand All @@ -70,18 +32,21 @@ jobs:
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0

- name: Restore Dependencies From cache
uses: actions/cache@v3
## 依赖下载完成后,或执行思维导图编译
- name: PNPM Install
uses: pnpm/action-setup@v2
with:
path: |
node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}

version: 7
run_install: |
args: [--frozen-lockfile, --registry=https://registry.npmmirror.com]
## 支持思维导图转化
- name: Build Mark-Map
run: |
./scripts/mark-map
# - name: Install Node.js
# uses: actions/setup-node@v3
# with:
# node-version: 18.18.0
# ## 淘宝镜像加速
# registry-url: 'https://registry.npmmirror.com'
# cache: 'pnpm'

# 运行构建脚本
- name: Build VuePress Site
Expand All @@ -98,8 +63,6 @@ jobs:
## 部署到vercel平台
deploy-vercel:
name: "部署到Vercel平台"
needs:
- install-init
runs-on: macos-latest
if: github.repository == '142vip/408CSFamily'
steps:
Expand All @@ -110,34 +73,22 @@ jobs:
# “最近更新时间” 等 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: Build Mark-Map
run: |
./scripts/mark-map
## 注意: 这里的操作时间vercel平台配置的命令拉取下来,执行
- name: Pull Vercel Environment Information
run: vercel -v && vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
run: npm i vercel -g && vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}

## 注意:安装pnpm
## 执行vercel平台配置的命令
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}

## dist文件同步到vercel平台
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

## 版本发布
release:
name: "创建Github发布"
name: "Github版本发布"
runs-on: macos-latest
needs:
- install-init
## 主库master、next且执行release更新时执行
if: github.repository == '142vip/408CSFamily' && startsWith(github.event.head_commit.message, 'chore(release):')

Expand All @@ -149,11 +100,6 @@ jobs:
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0

## 支持思维导图转化
- name: Build Mark-Map
run: |
./scripts/mark-map
### 打成压缩包
- name: Create Zip Package
run: |
Expand Down
23 changes: 11 additions & 12 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,21 @@ jobs:
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0

## 依赖下载完成后,或执行思维导图编译
- name: PNPM Install
uses: pnpm/action-setup@v2
with:
version: 7

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18.18.0
## 淘宝镜像加速
registry-url: 'https://registry.npmmirror.com'
cache: 'pnpm'

- name: Install Dependencies
run: |
pnpm i --frozen-lockfile --registry https://registry.npmmirror.com
run_install: |
args: [--frozen-lockfile, --registry=https://registry.npmmirror.com]
# - name: Install Node.js
# uses: actions/setup-node@v3
# with:
# node-version: 18.18.0
# ## 淘宝镜像加速
# registry-url: 'https://registry.npmmirror.com'
# cache: 'pnpm'

- name: Cache Dependencies
uses: actions/cache@v3
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## 参考:https://pnpm.io/zh/npmrc#prefer-frozen-lockfile
## 锁定版本
engine-strict = true
shamefully-hoist=true
Expand Down

0 comments on commit dadfea4

Please sign in to comment.