Skip to content

Commit 1485d05

Browse files
authored
docs(readme): improve Cache example
Dynamically detect the Store directory and use the latest GitHub actions.
1 parent 10b4b0b commit 1485d05

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

README.md

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,41 @@ on:
9999

100100
jobs:
101101
cache-and-install:
102-
runs-on: ubuntu-latest
102+
runs-on: ubuntu-20.04
103103

104104
steps:
105-
build:
106-
- uses: actions/checkout@v2
107-
108-
- name: Cache pnpm modules
109-
uses: actions/cache@v2
110-
with:
111-
path: ~/.pnpm-store
112-
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
113-
restore-keys: |
114-
${{ runner.os }}-
115-
116-
- uses: pnpm/[email protected]
117-
with:
118-
version: 6.0.2
119-
run_install: true
105+
- name: Checkout
106+
uses: actions/checkout@v3
107+
with:
108+
fetch-depth: 0
109+
110+
- name: Install Node.js
111+
uses: actions/setup-node@v3
112+
with:
113+
node-version: 16
114+
115+
- uses: pnpm/[email protected]
116+
name: Install pnpm
117+
id: pnpm-install
118+
with:
119+
version: 7
120+
run_install: false
121+
122+
- name: Get pnpm store directory
123+
id: pnpm-cache
124+
run: |
125+
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
126+
127+
- uses: actions/cache@v3
128+
name: Setup pnpm cache
129+
with:
130+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
131+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
132+
restore-keys: |
133+
${{ runner.os }}-pnpm-store-
134+
135+
- name: Install dependencies
136+
run: pnpm install
120137
```
121138
122139
**Note:** You don't need to run `pnpm store prune` at the end; post-action has already taken care of that.

0 commit comments

Comments
 (0)