






















@@ -14,9 +14,25 @@ inputs:
1414required: false
1515default: "true"
1616use-actions-cache:
17-description: Whether to restore/save pnpm store with actions/cache.
17+description: Whether to restore pnpm store with actions/cache.
1818required: false
1919default: "true"
20+outputs:
21+cache-enabled:
22+description: Whether actions/cache restore was enabled.
23+value: ${{ steps.pnpm-cache-config.outputs.enabled }}
24+cache-hit:
25+description: Whether the pnpm store cache had an exact key hit.
26+value: ${{ steps.pnpm-cache-restore.outputs.cache-hit }}
27+cache-matched-key:
28+description: Cache key matched by restore, if any.
29+value: ${{ steps.pnpm-cache-restore.outputs.cache-matched-key }}
30+primary-key:
31+description: Primary pnpm store cache key.
32+value: ${{ steps.pnpm-cache-config.outputs.primary-key }}
33+store-path:
34+description: Resolved pnpm store path.
35+value: ${{ steps.pnpm-store.outputs.path }}
2036runs:
2137using: composite
2238steps:
@@ -46,18 +62,29 @@ runs:
4662shell: bash
4763run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
486449- - name: Restore pnpm store cache (exact key only)
50-if: inputs.use-actions-cache == 'true' && inputs.use-restore-keys != 'true'
51-uses: actions/cache@v5
52-with:
53-path: ${{ steps.pnpm-store.outputs.path }}
54-key: ${{ runner.os }}-pnpm-store-${{ inputs.cache-key-suffix }}-${{ hashFiles('pnpm-lock.yaml') }}
65+ - name: Resolve pnpm store cache keys
66+id: pnpm-cache-config
67+shell: bash
68+env:
69+CACHE_KEY_SUFFIX: ${{ inputs.cache-key-suffix }}
70+LOCKFILE_HASH: ${{ hashFiles('pnpm-lock.yaml') }}
71+USE_ACTIONS_CACHE: ${{ inputs.use-actions-cache }}
72+USE_RESTORE_KEYS: ${{ inputs.use-restore-keys }}
73+run: |
74+ set -euo pipefail
75+ echo "enabled=$USE_ACTIONS_CACHE" >> "$GITHUB_OUTPUT"
76+ echo "primary-key=${RUNNER_OS}-pnpm-store-${CACHE_KEY_SUFFIX}-${LOCKFILE_HASH}" >> "$GITHUB_OUTPUT"
77+ if [ "$USE_RESTORE_KEYS" = "true" ]; then
78+ echo "restore-keys=${RUNNER_OS}-pnpm-store-${CACHE_KEY_SUFFIX}-" >> "$GITHUB_OUTPUT"
79+ else
80+ echo "restore-keys=" >> "$GITHUB_OUTPUT"
81+ fi
558256- - name: Restore pnpm store cache (with fallback keys)
57-if: inputs.use-actions-cache == 'true' && inputs.use-restore-keys == 'true'
58-uses: actions/cache@v5
83+ - name: Restore pnpm store cache
84+id: pnpm-cache-restore
85+if: inputs.use-actions-cache == 'true'
86+uses: actions/cache/restore@v5
5987with:
6088path: ${{ steps.pnpm-store.outputs.path }}
61-key: ${{ runner.os }}-pnpm-store-${{ inputs.cache-key-suffix }}-${{ hashFiles('pnpm-lock.yaml') }}
62-restore-keys: |
63- ${{ runner.os }}-pnpm-store-${{ inputs.cache-key-suffix }}-
89+key: ${{ steps.pnpm-cache-config.outputs.primary-key }}
90+restore-keys: ${{ steps.pnpm-cache-config.outputs.restore-keys }}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。