-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathaction.yml
More file actions
76 lines (70 loc) · 2.93 KB
/
Copy pathaction.yml
File metadata and controls
76 lines (70 loc) · 2.93 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
name: Setup Node and install dependencies
description: Configures npm, pnpm, or Yarn, restores the matching dependency cache, and installs dependencies.
inputs:
node-version:
description: Node.js version to use.
required: true
package-manager:
description: 'Package manager to use: npm, pnpm, or yarn.'
required: false
default: npm
package-manager-version:
description: 'pnpm version to install when package-manager is pnpm.'
required: false
default: '10'
cache-dependency-path:
description: 'Path to the package manager lockfile.'
required: false
default: package-lock.json
install-command:
description: 'Command used to install repository dependencies.'
required: false
default: npm ci
runs:
using: composite
steps:
- name: Validate package manager
shell: bash
env:
PACKAGE_MANAGER: ${{ inputs.package-manager }}
run: |
if [ "$PACKAGE_MANAGER" != "npm" ] && [ "$PACKAGE_MANAGER" != "pnpm" ] && [ "$PACKAGE_MANAGER" != "yarn" ]; then
echo "Unsupported package manager: $PACKAGE_MANAGER. Expected npm, pnpm, or yarn."
exit 1
fi
- name: Setup pnpm
if: inputs.package-manager == 'pnpm'
uses: pnpm/action-setup@v4
with:
version: ${{ inputs.package-manager-version }}
- name: Setup Node.js and restore dependency cache
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.package-manager }}
cache-dependency-path: ${{ inputs.cache-dependency-path }}
- name: Resolve install command
id: install-command
shell: bash
env:
INSTALL_COMMAND: ${{ inputs.install-command }}
PACKAGE_MANAGER: ${{ inputs.package-manager }}
run: |
if [ "$INSTALL_COMMAND" = "npm ci" ]; then
case "$PACKAGE_MANAGER" in
pnpm) INSTALL_COMMAND="pnpm install --frozen-lockfile" ;;
yarn) INSTALL_COMMAND="yarn install --network-timeout 600000" ;;
esac
fi
echo "value=$INSTALL_COMMAND" >> "$GITHUB_OUTPUT"
- name: Install npm dependencies
if: inputs.package-manager == 'npm' && steps.install-command.outputs.value == 'npm ci'
uses: salesforcecli/github-workflows/.github/actions/npmInstallWithRetries@main
- name: Install Yarn dependencies
if: inputs.package-manager == 'yarn' && steps.install-command.outputs.value == 'yarn install --network-timeout 600000'
uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
- name: Install custom or pnpm dependencies
if: (inputs.package-manager != 'npm' || steps.install-command.outputs.value != 'npm ci') && (inputs.package-manager != 'yarn' || steps.install-command.outputs.value != 'yarn install --network-timeout 600000')
uses: salesforcecli/github-workflows/.github/actions/retry@main
with:
command: ${{ steps.install-command.outputs.value }}