docs: add example of setup-node cache & pnpm v7

This commit is contained in:
ハン / Han 2022-05-27 15:30:41 +09:00 committed by GitHub
parent 57b9359b4c
commit c59794306a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.