I have a Docusaurus project which, when I run locally with npm run build
for the first time, takes 727 seconds to build. Once the build folder is already generated, running npm run build
takes only 234 seconds. I am trying to implement a similar caching mechanism for my pipeline:
- name: Cache npm dependencies
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Dependencies
run: npm ci
- name: Cache build folder
uses: actions/cache@v2
with:
path: build
key: ${{ runner.os }}-build-${{ hashFiles('**/build/**') }}
restore-keys: |
${{ runner.os }}-build-
- name: Build Docs
env:
run: npm run build
I can see that for the build folder the cache gets restored:
12s
Run actions/cache@v2
Received 0 of 208433371 (0.0%), 0.0 MBs/sec
Received 67108864 of 208433371 (32.2%), 32.0 MBs/sec
Received 167772160 of 208433371 (80.5%), 53.3 MBs/sec
Received 208433371 of 208433371 (100.0%), 56.4 MBs/sec
Cache Size: ~199 MB (208433371 B)
/usr/bin/tar -z -xf /home/runner/work/_temp/270df659-fec8-4690-9d84-17fc24256fd9/cache.tgz -P -C /home/runner/work/myrepo/myrepo
Cache restored successfully
Cache restored from key: Linux-build-c1b2051987189b5de83695a87c9e2ac4ddb50489e21342cbf5eff3829882ed46
However, although it gets restored, the caching doesnt work and the Build Docs stage for both runs takes 20 minutes. How could I overcome this issue?
2