diff --git a/actions/cache-node-modules/action.yml b/actions/cache-node-modules/action.yml index 52d2e7ffd..ed47a7e7e 100644 --- a/actions/cache-node-modules/action.yml +++ b/actions/cache-node-modules/action.yml @@ -7,6 +7,11 @@ inputs: build: description: 'Extra commands to run if nothing is cached' required: false + default: 'echo' + build_on_cache_fail: + description: 'Whether you want to run `npm run --if-present build` if there is no cache + require: false + default: 'true' # defaulting to true to not break any existing users. cache_name: description: 'Cache name' required: false @@ -31,8 +36,11 @@ runs: ${{ inputs.directories }} key: ${{ runner.os }}-build-${{ inputs.cache_name }}-${{ github.sha }} - if: steps.cache.outputs.cache-hit != 'true' - run: | - npm install - npm run --if-present build - ${{ inputs.build }} + run: npm install + shell: bash + - if: steps.cache.outputs.cache-hit != 'true' && ${{ inputs.build_on_cache_fail }} == 'true' + run: npm run --if-present build + shell: bash + - if: steps.cache.outputs.cache-hit != 'true' && ${{ inputs.build }} != 'echo' + run: ${{ inputs.build }} shell: bash