Skip to content

Commit fc7716a

Browse files
committed
fix(ci): bootstrap Yarn before dependency caching
Signed-off-by: Emiliano Suñé <2395873+esune@users.noreply.github.com>
1 parent 8848053 commit fc7716a

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

.github/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This folder defines automation for the BC Digital Trust Showcase monorepo (`fron
66

77
**Path:** `.github/actions/setup-node/action.yml`
88

9-
**Purpose:** Install Node and enable Yarn dependency caching in one step.
9+
**Purpose:** Install Node, activate the repository's Yarn version through Corepack, and cache Yarn dependencies.
1010

1111
**Inputs:**
1212

@@ -16,7 +16,9 @@ This folder defines automation for the BC Digital Trust Showcase monorepo (`fron
1616

1717
**Behaviour:**
1818

19-
- Runs [`actions/setup-node@v4`](https://github.com/actions/setup-node) with `cache: yarn` and `cache-dependency-path: yarn.lock` (repository root). No separate `actions/cache` step and no `yarn` invocation before Node is installed.
19+
- Runs [`actions/setup-node@v4`](https://github.com/actions/setup-node) without Yarn caching so the runner's global Yarn version is not invoked during setup.
20+
- Enables Corepack, installs and verifies Yarn `4.18.0`, then caches the Yarn cache directory with a key containing the OS, Node version, Yarn version, and `yarn.lock` hash.
21+
- The cache key intentionally does not restore the previous `setup-node` Yarn cache; the old entry is left for GitHub's normal eviction policy.
2022

2123
**Usage:**
2224

.github/actions/setup-node/action.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Setup NodeJS
2-
description: Setup NodeJS with caching
2+
description: Setup NodeJS with Corepack and Yarn caching
33
author: 'timo@animo.id'
44

55
inputs:
@@ -14,11 +14,23 @@ runs:
1414
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
1515
with:
1616
node-version: ${{ inputs.node-version }}
17-
cache: yarn
18-
cache-dependency-path: yarn.lock
1917
- name: Enable Corepack
2018
shell: bash
21-
run: corepack enable
19+
run: |
20+
corepack enable
21+
corepack install --global yarn@4.18.0
22+
- name: Verify Yarn version
23+
shell: bash
24+
run: test "$(yarn --version)" = "4.18.0"
25+
- name: Get Yarn cache directory
26+
id: yarn-cache-dir
27+
shell: bash
28+
run: echo "dir=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
29+
- name: Cache Yarn dependencies
30+
uses: actions/cache@v4
31+
with:
32+
path: ${{ steps.yarn-cache-dir.outputs.dir }}
33+
key: yarn-${{ runner.os }}-node-${{ inputs.node-version }}-yarn-4.18.0-${{ hashFiles('yarn.lock') }}
2234

2335
branding:
2436
icon: scissors

0 commit comments

Comments
 (0)