mirror of
https://github.com/pnpm/action-setup.git
synced 2024-11-13 21:33:57 +00:00
docs(readme): improve and fix cache example
Dynamically detect the Store directory and use the latest GitHub actions.
This commit is contained in:
parent
10b4b0b462
commit
73e15250cb
39
README.md
39
README.md
@ -99,24 +99,39 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
cache-and-install:
|
cache-and-install:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
build:
|
- name: Checkout
|
||||||
- uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Cache pnpm modules
|
- name: Install Node.js
|
||||||
uses: actions/cache@v2
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.pnpm-store
|
node-version: 16
|
||||||
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
||||||
|
- uses: pnpm/action-setup@v2.0.1
|
||||||
|
name: Install pnpm
|
||||||
|
id: pnpm-install
|
||||||
|
with:
|
||||||
|
version: 7
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Get pnpm store directory
|
||||||
|
id: pnpm-cache
|
||||||
|
run: |
|
||||||
|
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
|
||||||
|
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
name: Setup pnpm cache
|
||||||
|
with:
|
||||||
|
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
||||||
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2.1.0
|
- name: Install dependencies
|
||||||
with:
|
run: pnpm install
|
||||||
version: 6.0.2
|
|
||||||
run_install: true
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** You don't need to run `pnpm store prune` at the end; post-action has already taken care of that.
|
**Note:** You don't need to run `pnpm store prune` at the end; post-action has already taken care of that.
|
||||||
|
Loading…
Reference in New Issue
Block a user