-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
45 lines (45 loc) · 2.07 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
name: mangs/super-cache-action
author: Eric L. Goldstein
description: Simple GitHub Action that improves cache performance over actions/cache's recommendations for Node.js projects
inputs:
cache-key-suffix:
default: ""
description: String appended to the end of the auto-generated cache key that allows for cache key customization (e.g. separate development and production caches with the latter using `npm ci --production`)
required: false
cache-targets:
default: ./node_modules
description: Single- or multi-line string wherein each line targets a resource to cache; can use globs
required: false
package-manager:
default: npm
description: Package manager target for caching operations
required: false
outputs:
cache-hit:
description: A string containing either 'true' or 'false' indicating if 'cache-targets' were fetched from cache and applied to the current workflow run
value: ${{ steps.package-manager-cache.outputs.cache-hit }}
runs:
using: composite
steps:
- name: Capture package manager version number
id: capture
run: echo "version-number=$(${{ inputs.package-manager }} --version)" >> $GITHUB_OUTPUT
shell: bash
- if: inputs.package-manager == 'npm'
id: npm
run: echo "hash=${{ hashFiles('**/package-lock.json') }}" >> $GITHUB_OUTPUT
shell: bash
- if: inputs.package-manager == 'pnpm'
id: pnpm
run: echo "hash=${{ hashFiles('**/pnpm-lock.yaml') }}" >> $GITHUB_OUTPUT
shell: bash
- if: inputs.package-manager == 'yarn'
id: yarn
run: echo "hash=${{ hashFiles('**/yarn.lock') }}" >> $GITHUB_OUTPUT
shell: bash
- if: inputs.package-manager == 'npm' || inputs.package-manager == 'pnpm' || inputs.package-manager == 'yarn'
uses: actions/cache@v4
id: package-manager-cache
with:
path: ${{ inputs.cache-targets }}
key: ${{ runner.os }}-${{ inputs.package-manager }}-v${{ steps.capture.outputs.version-number }}-${{ steps.npm.outputs.hash }}${{ steps.pnpm.outputs.hash }}${{ steps.yarn.outputs.hash }}-${{ inputs.cache-key-suffix }}