Skip to content

Commit

Permalink
Simpler cache for node modules
Browse files Browse the repository at this point in the history
  • Loading branch information
jolelievre committed Sep 14, 2023
1 parent 52e30ce commit ab1b77d
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/actions/install-node-modules/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,25 @@ runs:

# Try and restore cache if it exists, then build assets only (no npm ci needed)
- name: Restore dependencies
id: restore-dependencies
uses: actions/cache/restore@v3
id: save-dependencies
uses: actions/cache@v3
with:
path: ${{ steps.action-parameters.outputs.node-modules }}
key: node-modules-${{ inputs.node_version }}-${{ hashFiles(inputs.package_locks) }}
- name: Build assets only (dependencies came from cache)
if: steps.restore-dependencies.outputs.cache-hit == 'true'
if: steps.save-dependencies.outputs.cache-hit == 'true'
run: ${{ join(fromJson(steps.action-parameters.outputs.build-command), ' & ') }}
shell: bash
- name: Save dependencies
uses: actions/cache/save@v3
with:
path: ${{ steps.action-parameters.outputs.node-modules }}
key: ${{ steps.restore-dependencies.outputs.cache-primary-key }}

# If the cache was not restored we install npm, node_modules dependencies and then build the assets, then we save the cache
- name: Setup Node ${{ inputs.node_version }}
if: steps.restore-dependencies.outputs.cache-hit != 'true'
if: steps.save-dependencies.outputs.cache-hit != 'true'
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node_version }}
cache: 'npm'
cache-dependency-path: ${{ inputs.package_locks }}
- name: Install dependencies and build assets
if: steps.restore-dependencies.outputs.cache-hit != 'true'
if: steps.save-dependencies.outputs.cache-hit != 'true'
run: ${{ join(fromJson(steps.action-parameters.outputs.install-command), ' & ') }}
shell: bash

0 comments on commit ab1b77d

Please sign in to comment.