diff --git a/yarn-install/action.yml b/yarn-install/action.yml index 09be255..ced5d50 100644 --- a/yarn-install/action.yml +++ b/yarn-install/action.yml @@ -4,6 +4,12 @@ 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 @@ -11,6 +17,7 @@ outputs: yarn-cache-dir: description: The location of the global yarn cache value: ${{ steps.yarn-cache.outputs.dir }} + runs: using: 'composite' steps: @@ -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 + + 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.