From 4381d294bd7fff93241b4c30be2e3fb628bd372e Mon Sep 17 00:00:00 2001 From: secustor Date: Mon, 17 Feb 2025 15:30:53 +0100 Subject: [PATCH 1/3] feat(yarn-install): install corepack, to allow dynamic installation --- yarn-install/action.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/yarn-install/action.yml b/yarn-install/action.yml index 09be255..a58cea1 100644 --- a/yarn-install/action.yml +++ b/yarn-install/action.yml @@ -8,9 +8,13 @@ outputs: cache-hit: description: Whether the node_modules cache got an exact cache hit value: ${{ steps.cache-modules.outputs.cache-hit }} + corepack-version: + description: Version of corepack to use. Defaults to latest + default: 'latest' yarn-cache-dir: description: The location of the global yarn cache value: ${{ steps.yarn-cache.outputs.dir }} + runs: using: 'composite' steps: @@ -23,7 +27,13 @@ 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: | + npm install -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. From 9621d899e77ef391565edff1320c478b244ff1b1 Mon Sep 17 00:00:00 2001 From: secustor Date: Mon, 17 Feb 2025 15:36:46 +0100 Subject: [PATCH 2/3] fixup! feat(yarn-install): install corepack, to allow dynamic installation --- yarn-install/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn-install/action.yml b/yarn-install/action.yml index a58cea1..c204a0e 100644 --- a/yarn-install/action.yml +++ b/yarn-install/action.yml @@ -4,13 +4,13 @@ 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' outputs: cache-hit: description: Whether the node_modules cache got an exact cache hit value: ${{ steps.cache-modules.outputs.cache-hit }} - corepack-version: - description: Version of corepack to use. Defaults to latest - default: 'latest' yarn-cache-dir: description: The location of the global yarn cache value: ${{ steps.yarn-cache.outputs.dir }} From eb54e05c3c15cbffe5652e551416652f981e79b7 Mon Sep 17 00:00:00 2001 From: secustor Date: Mon, 17 Feb 2025 16:29:06 +0100 Subject: [PATCH 3/3] feat(yarn-install): add an optional force flag for yarn install --- yarn-install/action.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/yarn-install/action.yml b/yarn-install/action.yml index c204a0e..ced5d50 100644 --- a/yarn-install/action.yml +++ b/yarn-install/action.yml @@ -7,6 +7,9 @@ inputs: 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 @@ -31,7 +34,12 @@ runs: - name: prepare corepack shell: bash run: | - npm install -g corepack@${{ inputs.corepack-version }} + 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