Skip to content

Commit ffdd979

Browse files
committed
fix: delete stale pnpm store caches on main branch
1 parent 2a0dac9 commit ffdd979

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

.github/actions/node-setup/action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ runs:
4747
shell: bash
4848
run: pnpm store prune
4949

50+
# Cache keys are immutable, so every save creates a brand-new entry
51+
# instead of replacing the previous one — old pnpm-store entries for main
52+
# never get evicted by anything but GitHub's 10GB LRU quota. Delete them
53+
# here so main only ever carries the one store it actually needs.
54+
- name: Delete stale pnpm store caches
55+
if: github.ref == 'refs/heads/main' && inputs.save-cache == 'true'
56+
shell: bash
57+
env:
58+
GH_TOKEN: ${{ github.token }}
59+
run: |
60+
cacheIds=$(gh cache list --repo "${{ github.repository }}" --ref refs/heads/main --key "pnpm-store-${{ runner.os }}-" --limit 100 --json id --jq '.[].id')
61+
for id in $cacheIds; do
62+
echo "Deleting stale pnpm store cache $id"
63+
gh cache delete "$id" --repo "${{ github.repository }}" || true
64+
done
65+
5066
# Only main writes new cache entries — PRs restore-and-reuse but never
5167
# save, so open PRs stop each spawning their own throwaway ~700MB entry.
5268
- name: Save pnpm store

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
packages: write # Required for publishing to npm registry
2727
id-token: write # Required for OIDC token generation
2828
pull-requests: write # Required for changesets action to create PRs
29+
actions: write # Required to delete stale pnpm-store caches
2930
outputs:
3031
published: ${{ steps.changesets.outputs.published }}
3132
has-changesets: ${{ steps.changesets.outputs.has-changesets }}

0 commit comments

Comments
 (0)