-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathaction.yml
More file actions
57 lines (49 loc) · 1.86 KB
/
Copy pathaction.yml
File metadata and controls
57 lines (49 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Setup Node
description: General setup of node
inputs:
node-version:
default: 24
save-cache:
description: Whether to save the pnpm store cache on main (still restored either way)
default: 'true'
runs:
using: composite
steps:
- name: Setup pnpm
uses: pnpm/action-setup@v5
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
- name: Get pnpm store path
id: pnpm-store
shell: bash
run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
# Restore-keys fall back to the closest prior store even when the lockfile
# hash doesn't match exactly, so PRs reuse main's store instead of
# installing from scratch.
- name: Restore pnpm store
uses: actions/cache/restore@v4
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
pnpm-store-${{ runner.os }}-
- name: Install dependencies
shell: bash
run: pnpm install --frozen-lockfile
# Cache keys are immutable, so every lockfile change saves a brand-new
# store on top of the previous one and old package versions never get
# dropped. Pruning here keeps the saved cache scoped to what this
# lockfile actually needs instead of growing unbounded.
- name: Prune pnpm store
shell: bash
run: pnpm store prune
# Only main writes new cache entries — PRs restore-and-reuse but never
# save, so open PRs stop each spawning their own throwaway ~700MB entry.
- name: Save pnpm store
if: github.ref == 'refs/heads/main' && inputs.save-cache == 'true'
uses: actions/cache/save@v4
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}