-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
78 lines (68 loc) · 2.68 KB
/
action.yml
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
---
name: ⚙️ Monorepo install (pnpm)
description: 'Run pnpm install with enabled cache.'
inputs:
cwd:
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
required: false
default: '.'
enable-corepack:
description: 'Enable corepack'
required: false
default: 'false'
cache-prefix:
description: "Add a specific cache-prefix"
required: false
default: 'default'
cache-node-modules:
description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)'
required: false
default: 'false'
runs:
using: 'composite'
steps:
- name: ⚙️ Enable Corepack
if: inputs.enable-corepack == 'true'
shell: bash
working-directory: ${{ inputs.cwd }}
run: corepack enable
- name: ⚙️ Install pnpm
if: inputs.enable-corepack == 'false'
uses: pnpm/action-setup@v2
id: pnpm-install
with:
run_install: false
- name: 🌎 Expose pnpm config(s) through "$GITHUB_OUTPUT"
id: pnpm-config
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path | tr -d '\n')" >> $GITHUB_OUTPUT
echo "CURRENT_NODE_VERSION="node-$(node --version)"" >> $GITHUB_OUTPUT
echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT
- name: ♻️ Cache rotation keys
id: cache-rotation
shell: bash
run: |
echo "YEAR_MONTH=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT
- name: 🗄️ Setup pnpm cache
uses: actions/cache@v4
id: pnpm-store-cache
with:
path: ${{ steps.pnpm-config.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-
- name: ♻️ Restore node_modules
if: inputs.cache-node-modules == 'true'
id: pnpm-nm-cache
uses: actions/cache@v4
with:
path: ${{ inputs.cwd }}/**/node_modules
key: pnpm-nm-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.pnpm-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.pnpm-config.outputs.CURRENT_BRANCH }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
pnpm-nm-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.pnpm-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.pnpm-config.outputs.CURRENT_BRANCH }}-
- name: 📦 Install dependencies
shell: bash
run: pnpm install --no-frozen-lockfile --strict-peer-dependencies --prefer-offline
env:
HUSKY: '0'