Skip to content

Commit 696ee6d

Browse files
erik-slovakclaude
andauthored
fix: compute cache keys in dedicated step to ensure they are always available (#133)
Cache key outputs previously referenced `actions/cache/restore` step outputs, which are empty when `use-cache` is false (steps are skipped). Compute keys in an unconditional step so save-dependencies always receives valid cache keys. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9112a1f commit 696ee6d

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

.github/actions/install-dependencies-bun/action.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ outputs:
1212
value: ${{ steps.bun-cache-dir.outputs.dir }}
1313
download-cache-primary-key:
1414
description: The cache key used for restoring the bun cache
15-
value: ${{ steps.cache-restore-bun.outputs.cache-primary-key }}
15+
value: ${{ steps.cache-keys.outputs.download-cache-primary-key }}
1616
node-modules-primary-key:
1717
description: The cache key used for restoring the node modules
18-
value: ${{ steps.cache-restore-node-modules.outputs.cache-primary-key }}
18+
value: ${{ steps.cache-keys.outputs.node-modules-primary-key }}
1919
runs:
2020
using: 'composite'
2121
steps:
@@ -25,20 +25,25 @@ runs:
2525
- run: echo "dir=$(bun pm cache)" >> $GITHUB_OUTPUT
2626
shell: bash
2727
id: bun-cache-dir
28+
- run: |
29+
echo "download-cache-primary-key=${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}" >> $GITHUB_OUTPUT
30+
echo "node-modules-primary-key=${{ runner.os }}-node_modules-${{ hashFiles('bun.lock') }}" >> $GITHUB_OUTPUT
31+
shell: bash
32+
id: cache-keys
2833
- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
2934
if: inputs.use-cache == 'true'
3035
id: cache-restore-bun
3136
with:
3237
path: ${{ steps.bun-cache-dir.outputs.dir }}
33-
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}
38+
key: ${{ steps.cache-keys.outputs.download-cache-primary-key }}
3439
restore-keys: |
3540
${{ runner.os }}-bun-
3641
- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
3742
if: inputs.use-cache == 'true'
3843
id: cache-restore-node-modules
3944
with:
4045
path: node_modules
41-
key: ${{ runner.os }}-node_modules-${{ hashFiles('bun.lock') }}
46+
key: ${{ steps.cache-keys.outputs.node-modules-primary-key }}
4247
restore-keys: |
4348
${{ runner.os }}-node_modules-
4449
- run: bun install --frozen-lockfile

.github/actions/install-dependencies/action.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ outputs:
1212
value: ${{ steps.yarn-cache-dir.outputs.dir }}
1313
download-cache-primary-key:
1414
description: The cache key used for restoring the yarn cache
15-
value: ${{ steps.cache-restore-yarn.outputs.cache-primary-key }}
15+
value: ${{ steps.cache-keys.outputs.download-cache-primary-key }}
1616
node-modules-primary-key:
1717
description: The cache key used for restoring the node modules
18-
value: ${{ steps.cache-restore-node-modules.outputs.cache-primary-key }}
18+
value: ${{ steps.cache-keys.outputs.node-modules-primary-key }}
1919
runs:
2020
using: 'composite'
2121
steps:
@@ -25,20 +25,25 @@ runs:
2525
- run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
2626
shell: bash
2727
id: yarn-cache-dir
28+
- run: |
29+
echo "download-cache-primary-key=${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}" >> $GITHUB_OUTPUT
30+
echo "node-modules-primary-key=${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }}" >> $GITHUB_OUTPUT
31+
shell: bash
32+
id: cache-keys
2833
- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
2934
if: inputs.use-cache == 'true'
3035
id: cache-restore-yarn
3136
with:
3237
path: ${{ steps.yarn-cache-dir.outputs.dir }}
33-
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
38+
key: ${{ steps.cache-keys.outputs.download-cache-primary-key }}
3439
restore-keys: |
3540
${{ runner.os }}-yarn-
3641
- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
3742
if: inputs.use-cache == 'true'
3843
id: cache-restore-node-modules
3944
with:
4045
path: node_modules
41-
key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }}
46+
key: ${{ steps.cache-keys.outputs.node-modules-primary-key }}
4247
restore-keys: |
4348
${{ runner.os }}-node_modules-
4449
- run: yarn install --frozen-lockfile

0 commit comments

Comments
 (0)