Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion yarn-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ inputs:
cache-prefix:
description: The prefix to use for all cache keys to keep different environments separate
required: true
corepack-version:
description: Version of corepack to use. Defaults to latest
default: 'latest'
yarn-install-force:
description: Whether to force the installation of yarn via corepack
default: false
outputs:
cache-hit:
description: Whether the node_modules cache got an exact cache hit
value: ${{ steps.cache-modules.outputs.cache-hit }}
yarn-cache-dir:
description: The location of the global yarn cache
value: ${{ steps.yarn-cache.outputs.dir }}

runs:
using: 'composite'
steps:
Expand All @@ -23,7 +30,18 @@ runs:
# We use both yarn.lock and package.json as cache keys to ensure that
# changes to local monorepo packages bust the cache.
key: ${{ inputs.cache-prefix }}-node_modules-${{ hashFiles('yarn.lock', '**/package.json') }}


- name: prepare corepack
shell: bash
run: |
if [[ "${{ inputs.yarn-install-force }}" == "true" ]]; then
npm install --force -g corepack@${{ inputs.corepack-version }}
else
npm install -g corepack@${{ inputs.corepack-version }}
fi
Comment on lines +36 to +41

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be simplified a bit.

Suggested change
run: |
if [[ "${{ inputs.yarn-install-force }}" == "true" ]]; then
npm install --force -g corepack@${{ inputs.corepack-version }}
else
npm install -g corepack@${{ inputs.corepack-version }}
fi
env:
YARN_INSTALL_FORCE: ${{ inputs.yarn-install-force == 'true' && '--force' || '' }}
run: |
npm install $YARN_INSTALL_FORCE -g corepack@${{ inputs.corepack-version }}


corepack enable

# If we get a cache hit for node_modules, there's no need to bring in the global
# yarn cache or run yarn install, as all dependencies will be installed already.

Expand Down