-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Expand file tree
/
Copy pathaction.yml
More file actions
86 lines (77 loc) · 2.84 KB
/
Copy pathaction.yml
File metadata and controls
86 lines (77 loc) · 2.84 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
82
83
84
85
86
name: Setup workspace
description: Restore pnpm cache and install dependencies
inputs:
node-version:
description: Node.js version to install
required: false
default: '24'
pnpm-version:
description: pnpm version to install
required: false
default: '10.33.2'
runner-labels:
description: JSON array of labels selected for this job's runs-on value
required: false
default: '[]'
save-pnpm-cache:
description: Save a missing pnpm cache after install; trusted main seed jobs only
required: false
default: 'false'
runs:
using: composite
steps:
- name: Detect persistent pnpm store
id: persistent-pnpm-store
shell: bash
env:
RUNNER_LABELS_JSON: ${{ inputs.runner-labels }}
run: |
case "$RUNNER_LABELS_JSON" in
*'"od-persistent-ci"'*) persistent_enabled=true ;;
*) persistent_enabled=false ;;
esac
if [ "$persistent_enabled" = "true" ]; then
if [ -z "${OPEN_DESIGN_CI_CACHE:-}" ]; then
echo "runner-labels contains od-persistent-ci, but OPEN_DESIGN_CI_CACHE is not set" >&2
exit 1
fi
store_dir="$OPEN_DESIGN_CI_CACHE/pnpm-store"
mkdir -p "$store_dir"
{
echo "NPM_CONFIG_STORE_DIR=$store_dir"
echo "npm_config_store_dir=$store_dir"
} >> "$GITHUB_ENV"
echo "enabled=true" >> "$GITHUB_OUTPUT"
echo "path=$store_dir" >> "$GITHUB_OUTPUT"
else
echo "enabled=false" >> "$GITHUB_OUTPUT"
fi
- name: Setup pnpm
uses: pnpm/action-setup@v6.0.8
with:
version: ${{ inputs.pnpm-version }}
- name: Setup Node.js
uses: actions/setup-node@v6.4.0
with:
node-version: ${{ inputs.node-version }}
package-manager-cache: false
- name: Resolve pnpm store path
id: pnpm-store
shell: bash
run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
- name: Restore pnpm store
id: pnpm-cache-restore
if: ${{ steps.persistent-pnpm-store.outputs.enabled != 'true' }}
uses: actions/cache/restore@v5
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install dependencies
shell: bash
run: pnpm install --frozen-lockfile
- name: Save pnpm store
if: ${{ inputs.save-pnpm-cache == 'true' && steps.persistent-pnpm-store.outputs.enabled != 'true' && steps.pnpm-cache-restore.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') }}
uses: actions/cache/save@v5
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}