mirror of
https://git.bjxgj.com/xgj/xgj-actions.git
synced 2025-10-14 16:53:37 +08:00
feat: 添加 npm 依赖安装与缓存的 GitHub Action,支持多种包管理器,优化 CI/CD 流程,提供详细的缓存状态和安装总结。
This commit is contained in:
52
npm-install/examples/pnpm-monorepo.yml
Normal file
52
npm-install/examples/pnpm-monorepo.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
# pnpm monorepo项目示例
|
||||
name: pnpm Monorepo CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
install-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [16, 18, 20]
|
||||
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 设置pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 8
|
||||
|
||||
- name: 设置Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: 安装依赖
|
||||
id: install-deps
|
||||
uses: actions/xgj/npm-install@v1
|
||||
with:
|
||||
package-manager: 'pnpm'
|
||||
cache-prefix: 'monorepo'
|
||||
|
||||
- name: 显示缓存状态
|
||||
run: |
|
||||
echo "缓存命中: ${{ steps.install-deps.outputs.cache-hit }}"
|
||||
echo "缓存Key: ${{ steps.install-deps.outputs.cache-key }}"
|
||||
|
||||
- name: 运行所有包的测试
|
||||
run: pnpm run test --recursive
|
||||
|
||||
- name: 构建所有包
|
||||
run: pnpm run build --recursive
|
||||
|
||||
- name: 类型检查
|
||||
run: pnpm run type-check --recursive
|
Reference in New Issue
Block a user