feat: 添加 npm 依赖安装与缓存的 GitHub Action,支持多种包管理器,优化 CI/CD 流程,提供详细的缓存状态和安装总结。

This commit is contained in:
Lyda
2025-08-20 14:54:26 +08:00
parent fa6608e795
commit d13a6b9f38
7 changed files with 663 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
# 自定义安装命令示例
name: 自定义安装命令
on:
push:
branches: [ production ]
jobs:
production-build:
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 设置Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: 生产环境依赖安装
uses: actions/xgj/npm-install@v1
with:
package-manager: 'npm'
install-command: 'npm ci --only=production --ignore-scripts'
cache-prefix: 'production'
- name: 验证依赖
run: |
echo "检查生产依赖..."
npm ls --depth=0 --only=production
- name: 构建生产版本
run: npm run build:production
- name: 运行生产测试
run: npm run test:production
development-build:
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 设置Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: 开发环境依赖安装
uses: actions/xgj/npm-install@v1
with:
package-manager: 'npm'
install-command: 'npm install --include=dev'
cache-prefix: 'development'
- name: 运行开发工具
run: |
npm run lint
npm run test:coverage