Skip to content

Commit 73e1525

Browse files
committed
docs(readme): improve and fix cache example
Dynamically detect the Store directory and use the latest GitHub actions.
1 parent 10b4b0b commit 73e1525

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

README.md

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,39 @@ 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+
108+
- name: Install Node.js
109+
uses: actions/setup-node@v3
110+
with:
111+
node-version: 16
112+
113+
- uses: pnpm/[email protected]
114+
name: Install pnpm
115+
id: pnpm-install
116+
with:
117+
version: 7
118+
run_install: false
119+
120+
- name: Get pnpm store directory
121+
id: pnpm-cache
122+
run: |
123+
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
124+
125+
- uses: actions/cache@v3
126+
name: Setup pnpm cache
127+
with:
128+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
129+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
130+
restore-keys: |
131+
${{ runner.os }}-pnpm-store-
132+
133+
- name: Install dependencies
134+
run: pnpm install
120135
```
121136
122137
**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)