mirror of
https://github.com/pnpm/action-setup.git
synced 2025-04-11 05:49:34 +08:00
docs: add example of setup-node cache & pnpm v7
This commit is contained in:
parent
57b9359b4c
commit
c59794306a
96
README.md
96
README.md
|
@ -53,85 +53,65 @@ Location of `pnpm` and `pnpx` command.
|
||||||
### Just install pnpm
|
### Just install pnpm
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
install:
|
install:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: pnpm/action-setup@v2.1.0
|
- name: Install pnpm
|
||||||
|
uses: pnpm/action-setup@v2
|
||||||
with:
|
with:
|
||||||
version: 6.0.2
|
version: 7
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install pnpm and a few npm packages
|
### Install pnpm with Node.js and a few npm packages
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
on:
|
steps:
|
||||||
- push
|
- name: Checkout Repo
|
||||||
- pull_request
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
jobs:
|
- name: Install Node.js
|
||||||
install:
|
uses: actions/setup-node@v3
|
||||||
runs-on: ubuntu-latest
|
with:
|
||||||
|
node-version: 16
|
||||||
|
|
||||||
steps:
|
- name: Install pnpm
|
||||||
- uses: actions/checkout@v2
|
uses: pnpm/action-setup@v2
|
||||||
|
with:
|
||||||
- uses: pnpm/action-setup@v2.1.0
|
version: 7
|
||||||
with:
|
run_install: |
|
||||||
version: 6.0.2
|
- recursive: true
|
||||||
run_install: |
|
args: [--frozen-lockfile, --strict-peer-dependencies]
|
||||||
- recursive: true
|
- args: [--global, gulp, prettier, typescript]
|
||||||
args: [--frozen-lockfile, --strict-peer-dependencies]
|
|
||||||
- args: [--global, gulp, prettier, typescript]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use cache to reduce installation time
|
### Use cache to reduce installation time
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
on:
|
steps:
|
||||||
- push
|
- name: Checkout Repo
|
||||||
- pull_request
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
jobs:
|
- name: Install Node.js
|
||||||
cache-and-install:
|
uses: actions/setup-node@v3
|
||||||
runs-on: ubuntu-latest
|
with:
|
||||||
|
node-version: 16
|
||||||
|
cache: pnpm
|
||||||
|
|
||||||
steps:
|
- name: Install pnpm
|
||||||
- name: Checkout
|
uses: pnpm/action-setup@v2
|
||||||
uses: actions/checkout@v3
|
with:
|
||||||
|
version: 7
|
||||||
|
|
||||||
- name: Install Node.js
|
- name: Install Dependencies
|
||||||
uses: actions/setup-node@v3
|
run: pnpm install
|
||||||
with:
|
|
||||||
node-version: 16
|
|
||||||
|
|
||||||
- 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: |
|
|
||||||
${{ runner.os }}-pnpm-store-
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: pnpm install
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**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