Skip to content

Commit 4f76abd

Browse files
committed
ci: create shared setup-env action
1 parent 66ffa19 commit 4f76abd

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/actions/setup-env/action.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Setup env
2+
description: Sets up node and pnpm
3+
4+
inputs:
5+
pnpm-version:
6+
description: Version of pnpm to install
7+
required: false
8+
default: "9"
9+
node-version:
10+
description: Version of node to install
11+
required: false
12+
default: "18"
13+
cache-save:
14+
description: Whether to save the pnpm cache
15+
required: false
16+
default: "false"
17+
outputs:
18+
cache-hit:
19+
description: Whether the cache was restored
20+
value: ${{ steps.setup-node.outputs.cache-hit || steps.cache-restore.outputs.cache-hit }}
21+
22+
runs:
23+
using: composite
24+
steps:
25+
- uses: pnpm/action-setup@v4
26+
with:
27+
version: ${{ inputs.pnpm-version }}
28+
- uses: actions/setup-node@v4
29+
id: setup-node
30+
with:
31+
node-version: ${{ inputs.node-version }}
32+
cache: ${{ inputs.cache-save == 'true' && 'pnpm' || '' }}
33+
cache-dependency-path: "**/pnpm-lock.yaml"
34+
- id: pnpm
35+
if: inputs.cache-save == 'false'
36+
run: pnpm store path --silent | xargs -I {} -0 echo "path={}" | tee -a $GITHUB_OUTPUT
37+
shell: bash
38+
- uses: actions/cache/restore@v4
39+
id: cache-restore
40+
if: inputs.cache-save == 'false'
41+
with:
42+
path: ${{ steps.pnpm.outputs.path }}
43+
key: node-cache-${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}

0 commit comments

Comments
 (0)