mirror of
https://git.bjxgj.com/xgj/xgj-actions.git
synced 2025-10-14 11:23:37 +08:00
feat: 添加 npm 依赖安装与缓存的 GitHub Action,支持多种包管理器,优化 CI/CD 流程,提供详细的缓存状态和安装总结。
This commit is contained in:
50
npm-install/examples/force-install-with-stash.yml
Normal file
50
npm-install/examples/force-install-with-stash.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
# 强制安装 + Git Stash 示例
|
||||
name: 强制安装示例
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ hotfix/* ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
force-install:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 设置Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: 强制安装依赖
|
||||
id: force-install
|
||||
uses: actions/xgj/npm-install@v1
|
||||
with:
|
||||
package-manager: 'npm'
|
||||
force-install: 'true'
|
||||
enable-git-stash: 'true'
|
||||
cache-prefix: 'hotfix'
|
||||
|
||||
- name: 检查是否重新安装
|
||||
run: |
|
||||
if [[ "${{ steps.force-install.outputs.cache-hit }}" != "true" ]]; then
|
||||
echo "✅ 依赖已重新安装"
|
||||
echo "🔄 已执行git stash"
|
||||
else
|
||||
echo "ℹ️ 使用了缓存"
|
||||
fi
|
||||
|
||||
- name: 清理构建缓存
|
||||
if: steps.force-install.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
npm run clean
|
||||
echo "🧹 清理完成"
|
||||
|
||||
- name: 重新构建
|
||||
run: npm run build
|
||||
|
||||
- name: 运行完整测试套件
|
||||
run: npm run test:full
|
Reference in New Issue
Block a user