Skip to content

Commit 7ec3fc7

Browse files
committed
update
1 parent 010ed76 commit 7ec3fc7

File tree

1 file changed

+24
-32
lines changed

1 file changed

+24
-32
lines changed
Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,42 @@
1-
name: 'Setup Node.js and pnpm'
2-
description: 'Reusable action to setup Node.js and pnpm with caching'
3-
4-
inputs:
5-
node-version:
6-
description: 'Node.js version to install'
7-
required: false
8-
default: 'lts/*'
9-
enable-cache:
10-
description: 'Enable pnpm store caching'
11-
required: false
12-
default: 'true'
13-
frozen-lockfile:
14-
description: 'Use frozen lockfile for pnpm install'
15-
required: false
16-
default: 'true'
1+
name: Setup Node and pnpm
172

183
runs:
19-
using: 'composite'
4+
using: composite
205
steps:
21-
- name: Setup Node.js ${{ inputs.node-version }}
22-
uses: actions/setup-node@v4
6+
- uses: pnpm/action-setup@v4
7+
8+
- uses: actions/setup-node@v4
239
with:
24-
node-version: ${{ inputs.node-version }}
10+
node-version-file: .node-version
11+
registry-url: 'https://registry.npmjs.org'
12+
# see pnpm cache setting below
2513
env:
2614
GITHUB_TOKEN: ${{ github.token }}
2715

28-
- name: Setup pnpm
29-
uses: pnpm/action-setup@v4
30-
3116
- name: Get pnpm store directory
32-
if: inputs.enable-cache == 'true'
17+
id: store
3318
shell: bash
3419
run: |
35-
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
20+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
3621
37-
- name: Setup pnpm cache
38-
if: inputs.enable-cache == 'true'
22+
- name: Save and restore pnpm cache on main
3923
uses: actions/cache@v4
24+
if: ${{ github.ref_name == 'main' }}
4025
with:
41-
path: ${{ env.STORE_PATH }}
42-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
26+
path: ${{ steps.store.outputs.STORE_PATH }}
27+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
4328
restore-keys: |
4429
${{ runner.os }}-pnpm-store-
4530
46-
- name: Install dependencies
31+
- name: Restore pnpm cache on PR
32+
uses: actions/cache/restore@v4
33+
if: ${{ github.ref_name != 'main' }}
34+
with:
35+
path: ${{ steps.store.outputs.STORE_PATH }}
36+
key: |
37+
${{ runner.os }}-pnpm-store-
38+
39+
- run: pnpm install --frozen-lockfile --ignore-scripts
4740
shell: bash
48-
run: pnpm install${{ inputs.frozen-lockfile == 'true' && ' --frozen-lockfile' || '' }}
4941
env:
50-
GITHUB_TOKEN: ${{ github.token }}
42+
GITHUB_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)