-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
61 lines (59 loc) · 2 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
name: 'Install Packages With Cache'
description: 'Install Packages through yarn, with npm auth token and cache'
inputs:
npm-token:
description: 'NPM Token for private package'
required: false
default: ''
is-monorepo:
description: 'Using in a monorepo project?'
required: false
default: "false"
skip-cache:
description: 'Wanna skip cache?'
required: false
default: "false"
runs:
using: 'composite'
steps:
# cache configs
- name: Output OS version
id: output-os-version
run: echo "version=`lsb_release -d -s`" >> $GITHUB_OUTPUT
shell: bash
- name: Output Node version
id: output-node-version
run: echo "version=`node -v`" >> $GITHUB_OUTPUT
shell: bash
- name: Cache monorepo node_modules
if: ${{ !fromJSON(inputs.skip-cache) && fromJSON(inputs.is-monorepo) }}
uses: actions/cache@v4
with:
path: "**/node_modules/"
key: ${{ steps.output-os-version.outputs.version }}-node${{ steps.output-node-version.outputs.version }}-yarn-${{ hashFiles('**/yarn.lock') }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: "10"
- name: Cache single-repo node_modules
if: ${{ !fromJSON(inputs.skip-cache) && !fromJSON(inputs.is-monorepo) }}
uses: actions/cache@v4
with:
path: "node_modules/"
key: ${{ steps.output-os-version.outputs.version }}-node${{ steps.output-node-version.outputs.version }}-yarn-${{ hashFiles('yarn.lock') }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: "10"
# install packages
- name: Set .npmrc to use npm auth
if: ${{ inputs.npm-token }}
run: |
echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> .npmrc
echo "#always-auth=true" >> .npmrc
shell: bash
- name: Install packages without updating lock file
run: yarn --frozen-lockfile
env:
NPM_TOKEN: ${{ inputs.npm-token }}
shell: bash
- name: Delete .npmrc
if: ${{ inputs.npm-token }}
run: rm -f .npmrc
shell: bash