-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
79 lines (71 loc) · 2.12 KB
/
action.yaml
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
name: setup-node
description: Installs NodeJS and project dependencies
inputs:
node_version:
description: NodeJS version (latest LTS by default)
required: false
default: ''
node_version_file:
description: NodeJS version file
required: false
default: ''
working_directory:
description: Working directory
required: false
default: '.'
runs:
using: composite
steps:
- name: Check NodeJS version
id: check-node-version
shell: bash
working-directory: ${{ inputs.working_directory }}
env:
NODE_VERSION: ${{ inputs.node_version }}
NODE_VERSION_FILE: ${{ inputs.node_version_file }}
run: |
if [ -z "$NODE_VERSION" ] && [ -z "$NODE_VERSION_FILE" ]; then
echo "Must set either node_version or node_version_file"
exit 1
elif [ -n "$NODE_VERSION" ] && [ -n "$NODE_VERSION_FILE" ]; then
echo "Cannot set both node_version and node_version_file"
exit 1
fi
- name: Setup NodeJS
id: install-node
uses: actions/setup-node@v4
with:
node-version: '${{ inputs.node_version }}'
node-version-file: '${{ inputs.node_version_file }}'
cache: yarn
cache-dependency-path: ${{ inputs.working_directory }}/yarn.lock
- name: Check yarn.lock
id: check-yarn-lock
shell: bash
run: |
if [ -f yarn.lock ]; \
then \
echo "has-lock=true" >> $GITHUB_OUTPUT; \
else \
echo "has-lock=false" >> $GITHUB_OUTPUT; \
fi
- name: Install dependencies
id: install-node-deps
shell: bash
working-directory: ${{ inputs.working_directory }}
env:
HAS_YARN_LOCK: ${{ steps.check-yarn-lock.outputs.has-lock }}
run: |
if [ "${HAS_YARN_LOCK}" == "true" ];
then
yarn install --frozen-lockfile --immutable;
else
yarn install;
fi
outputs:
node-version:
description: NodeJS version
value: ${{ steps.install-node.outputs.node-version }}
cache-hit:
description: Cache hit
value: ${{ steps.install-node.outputs.cache-hit }}