From df28af62a77c3ec1e888897a4a59125f713d9e81 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Wed, 14 Sep 2022 13:33:26 -0700 Subject: [PATCH] feat: build opt-out for cache-node-modules action I've used this action several times and did not know that it was also called `npm run build`. The build step can increase a workflow's runtime and complexity, and I usually don't want to do that. I think it's useful, but since there was already support for `inputs.build`, I think it's unnecessary. An opt-out (since we don't want to break existing users) will help me out a lot. --- actions/cache-node-modules/action.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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