-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (46 loc) · 2.1 KB
/
cache-dependencies.yaml
File metadata and controls
53 lines (46 loc) · 2.1 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
name: Cache Dependencies
on:
workflow_call:
inputs:
working-directory:
type: string
default: .
required: false
additional-working-directory:
type: string
required: false
jobs:
cache-dependencies:
name: Cache Dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
# A simple node script that converts secrets to env vars
# Use specific commit SHA to prevent someone stealing that repo
# - Useful for passing dynamic secrets to env variables, e.g. NPM_TOKEN to `npm ci` step
- uses: oNaiPs/secrets-to-env-action@b64e0192bc4bd2ec0682dee8696470d4866577fa
with:
secrets: ${{ toJSON(secrets) }}
- name: Cache dependencies npm
id: check-dependencies-cache
uses: actions/cache@v5
with:
path: ${{ inputs.working-directory }}/node_modules
key: modules-npm-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/package-lock.json', inputs.working-directory)) }}
- name: Cache additional dependencies npm
if: inputs.additional-working-directory != ''
id: check-additional-dependencies-cache
uses: actions/cache@v5
with:
path: ${{ inputs.additional-working-directory }}/node_modules
key: modules-npm-${{ inputs.additional-working-directory }}-${{ hashFiles(format('{0}/package-lock.json', inputs.additional-working-directory)) }}
- name: install npm dependencies
if: steps.check-dependencies-cache.outputs.cache-hit != 'true'
run: |
cd ${{ inputs.working-directory }}
npm ci
- name: install additional npm dependencies
if: steps.check-additional-dependencies-cache.outputs.cache-hit != 'true'
run: |
cd ${{ inputs.additional-working-directory }}
npm ci