Skip to content

Commit f61d17e

Browse files
authored
add cache in CI/CD description (#6089)
1 parent 2017384 commit f61d17e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/content/configuration/cache.mdx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,3 +438,43 @@ module.exports = {
438438
```
439439

440440
W> Don't share the cache between calls with different options.
441+
442+
## Setup cache in CI/CD system
443+
444+
Filesystem cache allows to share cache between builds in CI. To setup cache:
445+
446+
- CI should have an option to share cache between builds.
447+
- CI should run job in the same absolute path. This is important since webpack cache files store absolute paths.
448+
449+
### GitLab CI/CD
450+
451+
Common config could looks like
452+
453+
```yaml
454+
variables:
455+
# fallback to use "main" branch cache, requires GitLab Runner 13.4
456+
CACHE_FALLBACK_KEY: main
457+
458+
# this is webpack build job
459+
build-job:
460+
cache:
461+
key: '$CI_COMMIT_REF_SLUG' # branch/tag name
462+
paths:
463+
# cache directory
464+
# make sure that you don't run "npm ci" in this job or change default cache directory
465+
# otherwise "npm ci" will prune cache files
466+
- node_modules/.cache/webpack/
467+
```
468+
469+
### Github actions
470+
471+
```yaml
472+
- uses: actions/cache@v3
473+
with:
474+
# cache directory
475+
path: node_modules/.cache/webpack/
476+
key: ${{ GITHUB_REF_NAME }}-webpack-build
477+
# fallback to use "main" branch cache
478+
restore-keys: |
479+
main-webpack-build
480+
```

0 commit comments

Comments
 (0)