From 9ac33e53e6cb03b5bdcc79d321c7e955a5b0ff85 Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Wed, 27 Aug 2025 12:52:37 +0200 Subject: [PATCH] Store Corepack tools in GitHub cache (#42168) Closes #42165 Signed-off-by: Jon Koops --- .github/actions/corepack-setup/action.yml | 36 +++++++++++++++++++++++ .github/actions/pnpm-setup/action.yml | 5 ++-- 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 .github/actions/corepack-setup/action.yml diff --git a/.github/actions/corepack-setup/action.yml b/.github/actions/corepack-setup/action.yml new file mode 100644 index 00000000000..f5df0af5b14 --- /dev/null +++ b/.github/actions/corepack-setup/action.yml @@ -0,0 +1,36 @@ +name: Setup Corepack +description: Sets up and caches the Corepack tools to speed up the build. + +runs: + using: composite + steps: + - name: Enable Corepack + shell: bash + run: corepack enable + + - id: cache-key + name: Generate key for tools cache + shell: bash + working-directory: js + run: echo "key=corepack-tools-$(jq -r '.packageManager' package.json)" >> $GITHUB_OUTPUT + + - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + id: cache + name: Cache Corepack tools + with: + # See: https://github.com/nodejs/corepack?tab=readme-ov-file#offline-workflow + path: ./js/corepack.tgz + key: ${{ runner.os }}-${{ steps.cache-key.outputs.key }} + + - name: Install Corepack tools from cache + if: steps.cache.outputs.cache-hit == 'true' + shell: bash + working-directory: js + run: corepack install -g --cache-only ./corepack.tgz + + - name: Package Corepack tools + if: steps.cache.outputs.cache-hit != 'true' + shell: bash + working-directory: js + run: corepack pack + diff --git a/.github/actions/pnpm-setup/action.yml b/.github/actions/pnpm-setup/action.yml index 6eb1853a97c..313fbba0623 100644 --- a/.github/actions/pnpm-setup/action.yml +++ b/.github/actions/pnpm-setup/action.yml @@ -16,9 +16,8 @@ runs: node-version: ${{ inputs.node-version }} check-latest: true - - name: Enable Corepack - shell: bash - run: corepack enable + - name: Setup Corepack + uses: ./.github/actions/corepack-setup - name: PNPM store cache uses: ./.github/actions/pnpm-store-cache