-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
81 lines (72 loc) · 2.38 KB
/
action.yml
File metadata and controls
81 lines (72 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: 'Setup Node.js with pnpm'
description: 'Setup Node.js with pnpm and configure dependency caching for optimal performance'
author: 'Samuel Ho'
branding:
icon: 'package'
color: 'blue'
inputs:
node-version:
description: 'Node.js version to use'
required: false
default: '20'
pnpm-version:
description: 'pnpm version to use'
required: false
default: '8'
cache:
description: 'Enable dependency caching'
required: false
default: 'true'
working-directory:
description: 'Working directory for pnpm commands'
required: false
default: '.'
outputs:
cache-hit:
description: 'Whether dependencies were restored from cache'
value: ${{ steps.cache-pnpm.outputs.cache-hit }}
pnpm-store-path:
description: 'Path to pnpm store directory'
value: ${{ steps.pnpm-store.outputs.dir }}
runs:
using: 'composite'
steps:
- name: Setup pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: ${{ inputs.pnpm-version }}
run_install: false
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.cache == 'true' && 'pnpm' || '' }}
cache-dependency-path: ${{ inputs.working-directory }}/pnpm-lock.yaml
- name: Get pnpm store directory
if: inputs.cache == 'true'
id: pnpm-store
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Cache pnpm store
if: inputs.cache == 'true'
id: cache-pnpm
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ${{ steps.pnpm-store.outputs.dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles(format('{0}/pnpm-lock.yaml', inputs.working-directory)) }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
shell: bash
working-directory: ${{ inputs.working-directory }}
run: pnpm install --frozen-lockfile
- name: Output cache status
shell: bash
run: |
if [ "${{ steps.cache-pnpm.outputs.cache-hit }}" == "true" ]; then
echo "✅ Dependencies restored from cache"
else
echo "📦 Dependencies installed fresh"
fi