mirror of
https://git.bjxgj.com/xgj/xgj-actions.git
synced 2025-10-14 17:13:38 +08:00
feat: 添加 npm 依赖安装与缓存的 GitHub Action,支持多种包管理器,优化 CI/CD 流程,提供详细的缓存状态和安装总结。
This commit is contained in:
61
npm-install/examples/custom-command.yml
Normal file
61
npm-install/examples/custom-command.yml
Normal 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
|
Reference in New Issue
Block a user