Skip to content

Commit

Permalink
Add skip-cache option for yarn-install action
Browse files Browse the repository at this point in the history
  • Loading branch information
ascrazy committed Dec 11, 2024
1 parent 811ad4b commit 0092dc2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions yarn-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ inputs:
description: How many times to retry installing. This is specially useful if the building of packages might fail because of network connections
default: "1"
required: false
skip-cache:
description: Skip cache and always install dependencies
default: "false"
required: false
outputs:
cache-hit:
description: "Indicates an exact match was found for `node_modules` || boolean"
Expand All @@ -35,6 +39,7 @@ runs:
shell: bash

- name: Get yarn cache
if: "inputs.skip-cache != 'true'"
id: yarn-cache
run: echo dir=$(yarn cache dir) >> $GITHUB_OUTPUT
shell: bash
Expand All @@ -52,15 +57,15 @@ runs:
shell: bash

- name: Checkout `cache action` from actions repository
if: "inputs.checkout-token && (contains(runner.name, 'inf-gha-runners') || contains(runner.name, 'ubuntu2204'))"
if: "inputs.skip-cache != 'true' && inputs.checkout-token && (contains(runner.name, 'inf-gha-runners') || contains(runner.name, 'ubuntu2204'))"
uses: actions/checkout@v4
with:
repository: toptal/actions
token: ${{ inputs.checkout-token }}
path: ./.github/cache_action/

- name: Cache yarn and node_modules folder
if: "inputs.checkout-token && (contains(runner.name, 'inf-gha-runners') || contains(runner.name, 'ubuntu2204'))"
if: "inputs.skip-cache != 'true' && inputs.checkout-token && (contains(runner.name, 'inf-gha-runners') || contains(runner.name, 'ubuntu2204'))"
uses: ./.github/cache_action/cache/
id: node-modules-cache-custom
with:
Expand All @@ -73,7 +78,7 @@ runs:
key: ${{ runner.os }}-${{ runner.arch }}-node-${{ steps.set-node-version.outputs.version }}-yarn-node_modules-${{ hashFiles(format('{0}/yarn.lock', inputs.path), format('{0}/tmp-workspaces.json', inputs.path)) }}-${{ inputs.cache-version }}

- name: Cache yarn and node_modules folder
if: "!(inputs.checkout-token && (contains(runner.name, 'inf-gha-runners') || contains(runner.name, 'ubuntu2204')))"
if: "inputs.skip-cache != 'true' && !(inputs.checkout-token && (contains(runner.name, 'inf-gha-runners') || contains(runner.name, 'ubuntu2204')))"
uses: actions/cache@v4
id: node-modules-cache
with:
Expand Down

0 comments on commit 0092dc2

Please sign in to comment.