I'm trying to apply 2 type of caches,
- cache for yarn on my build step.
- cache for my 3 next apps
The project is uses yarn workspaces which has 3 projects under /packages/renderers/
My build is triggered by tag creation.
name: Build & Deploy
on:
push:
tags:
- 'v1.*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/cache@v2
with:
path: |
${{ github.workspace }}/packages/renderers/*/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('yarn.lock') }}
- name: Install Packages
run: yarn install --frozen-lockfile
env:
CI: true
- name: Build artifacts
run: yarn build
env:
CI: true


I've tried to debug, found out that the recommended doc config for yarn cache which uses hashFiles('**/yarn.lock') is wrong cause it picks yarn.lock files from node_module (as part of the key) at the end of the build, but tries to restore with empty node_modules which produced different hash.
I've changed this and now the restore key is the same but it still claims that cache not found.
I'm trying to apply 2 type of caches,
The project is uses yarn workspaces which has 3 projects under
/packages/renderers/My build is triggered by tag creation.
I've tried to debug, found out that the recommended doc config for yarn cache which uses
hashFiles('**/yarn.lock')is wrong cause it picks yarn.lock files fromnode_module(as part of the key) at the end of the build, but tries to restore with emptynode_moduleswhich produced different hash.I've changed this and now the restore key is the same but it still claims that
cache not found.