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:
89
npm-install/examples/multi-project.yml
Normal file
89
npm-install/examples/multi-project.yml
Normal file
@@ -0,0 +1,89 @@
|
||||
# 多项目/多目录示例
|
||||
name: 多项目构建
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
frontend:
|
||||
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: 'yarn'
|
||||
node-modules-path: './frontend/node_modules'
|
||||
cache-prefix: 'frontend'
|
||||
|
||||
- name: 构建前端
|
||||
working-directory: ./frontend
|
||||
run: yarn build
|
||||
|
||||
- name: 前端测试
|
||||
working-directory: ./frontend
|
||||
run: yarn test
|
||||
|
||||
backend:
|
||||
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'
|
||||
node-modules-path: './backend/node_modules'
|
||||
cache-prefix: 'backend'
|
||||
|
||||
- name: 后端测试
|
||||
working-directory: ./backend
|
||||
run: npm test
|
||||
|
||||
- name: 构建后端
|
||||
working-directory: ./backend
|
||||
run: npm run build
|
||||
|
||||
docs:
|
||||
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: 'pnpm'
|
||||
node-modules-path: './docs/node_modules'
|
||||
cache-prefix: 'docs'
|
||||
|
||||
- name: 构建文档
|
||||
working-directory: ./docs
|
||||
run: pnpm build
|
||||
|
||||
- name: 部署文档
|
||||
if: github.ref == 'refs/heads/main'
|
||||
working-directory: ./docs
|
||||
run: pnpm deploy
|
Reference in New Issue
Block a user