更新 action.yml,添加 pnpm 缓存逻辑以优化依赖安装过程

This commit is contained in:
严浩
2024-09-30 21:44:25 +08:00
parent 55e731e29b
commit 268b58e234

View File

@ -38,6 +38,7 @@ runs:
if [[ -f "pnpm-lock.yaml" ]]; then if [[ -f "pnpm-lock.yaml" ]]; then
echo "pnpm-lock.yaml exists" echo "pnpm-lock.yaml exists"
echo "pnpm-lock-exists=true" >> $GITHUB_OUTPUT echo "pnpm-lock-exists=true" >> $GITHUB_OUTPUT
echo "cache=pnpm" >> $GITHUB_OUTPUT
else else
echo "pnpm-lock.yaml does not exist" echo "pnpm-lock.yaml does not exist"
fi fi
@ -47,7 +48,7 @@ runs:
- uses: actions/setup-node@v4 # https://github.com/actions/setup-node?tab=readme-ov-file#usage - uses: actions/setup-node@v4 # https://github.com/actions/setup-node?tab=readme-ov-file#usage
with: with:
node-version: lts/* node-version: lts/*
# cache: 'pnpm' # TODO: 判断是否有pnpm-lock.yaml文件有则启用缓存 cache: ${{ steps.prepare.outputs.cache }}
- name: 📦 Install Project Dependencies - name: 📦 Install Project Dependencies
if: steps.prepare.outputs.pnpm-lock-exists == 'true' if: steps.prepare.outputs.pnpm-lock-exists == 'true'
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile