-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
action.yml
89 lines (81 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
79
80
81
82
83
84
85
86
87
88
89
# This is the composite action:
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
#
# Composite actions have some limitations:
# - many contexts are unavailable, e.g. `runner`
# - `env` can be specified per-step only
# - if `run` is used, `shell` must be explicitly specified
name: 'Setup Node and install dependencies'
description: 'Setup Node and install dependencies using cache'
inputs:
node-version:
description: 'Node version'
required: true
os:
description: 'Composite actions do not support `runner.os`, so it must be passed in as an input'
required: true
save-cache:
description: 'Save cache when needed'
required: false
default: 'false'
runs:
using: 'composite'
steps:
- name: Calculate `CACHE_KEY`
shell: bash
run: |
echo 'CACHE_KEY=node_modules-${{
inputs.os
}}-${{
inputs.node-version
}}-${{
hashFiles('pnpm-lock.yaml')
}}' >> "$GITHUB_ENV"
- name: Restore `node_modules`
id: node-modules-restore
uses: actions/cache/restore@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: node_modules
key: ${{ env.CACHE_KEY }}
enableCrossOsArchive: true
- name: Calculate `CACHE_HIT`
shell: bash
run: |
echo 'CACHE_HIT=${{
(steps.node-modules-restore.outputs.cache-hit == 'true') && 'true' || ''
}}' >> "$GITHUB_ENV"
- name: Enable corepack
shell: bash
run: corepack enable
- name: Setup Node
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: ${{ inputs.node-version }}
cache: ${{ env.CACHE_HIT != 'true' && 'pnpm' || '' }}
- name: Install dependencies
uses: nick-fields/retry@14672906e672a08bd6eeb15720e9ed3ce869cdd4 # v2.9.0
if: env.CACHE_HIT != 'true'
with:
timeout_minutes: 10
max_attempts: 3
command: pnpm install --frozen-lockfile
- name: Write `node_modules` cache
if: inputs.save-cache == 'true' && env.CACHE_HIT != 'true'
uses: actions/cache/save@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: node_modules
key: ${{ env.CACHE_KEY }}
enableCrossOsArchive: true
- name: Generate files
shell: bash
run: >
if [[ -d lib ]]; then
pnpm prepare:generate;
fi
- name: Git config
shell: bash
run: |
git config --global core.autocrlf false
git config --global core.symlinks true
git config --global user.email 'renovate@whitesourcesoftware.com'
git config --global user.name 'Renovate Bot'