@@ -120,6 +120,11 @@ jobs:
120120 changed_browser : ${{ steps.changed.outputs.browser }}
121121 changed_browser_integration : ${{ steps.changed.outputs.browser_integration }}
122122 changed_any_code : ${{ steps.changed.outputs.any_code }}
123+ # Note: These next three have to be checked as strings ('true'/'false')!
124+ is_master : ${{ github.ref == 'refs/heads/master' }}
125+ is_release : ${{ startsWith(github.ref, 'refs/heads/release/') }}
126+ force_skip_cache :
127+ ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci-skip-cache') }}
123128
124129 job_install_deps :
125130 name : Install Dependencies
@@ -139,14 +144,19 @@ jobs:
139144 - name : Compute dependency cache key
140145 id : compute_lockfile_hash
141146 run : echo "hash=${{ hashFiles('yarn.lock') }}" >> "$GITHUB_OUTPUT"
147+
148+ # When the `ci-skip-cache` label is added to a PR, we always want to skip dependency cache
142149 - name : Check dependency cache
143150 uses : actions/cache@v3
144151 id : cache_dependencies
152+ if : needs.job_get_metadata.outputs.force_skip_cache == 'false'
145153 with :
146154 path : ${{ env.CACHED_DEPENDENCY_PATHS }}
147155 key : ${{ steps.compute_lockfile_hash.outputs.hash }}
156+
148157 - name : Install dependencies
149- if : steps.cache_dependencies.outputs.cache-hit == ''
158+ if :
159+ steps.cache_dependencies.outputs.cache-hit == '' || needs.job_get_metadata.outputs.force_skip_cache == 'true'
150160 run : yarn install --ignore-engines --frozen-lockfile
151161 outputs :
152162 dependency_cache_key : ${{ steps.compute_lockfile_hash.outputs.hash }}
@@ -168,12 +178,35 @@ jobs:
168178 with :
169179 path : ${{ env.CACHED_DEPENDENCY_PATHS }}
170180 key : ${{ needs.job_install_deps.outputs.dependency_cache_key }}
181+
171182 - name : Check build cache
172183 uses : actions/cache@v3
173184 id : cache_built_packages
185+ if : needs.job_get_metadata.outputs.force_skip_cache == 'false'
174186 with :
175187 path : ${{ env.CACHED_BUILD_PATHS }}
176188 key : ${{ env.BUILD_CACHE_KEY }}
189+
190+ - name : NX cache
191+ uses : actions/cache@v3
192+ # Disable cache when:
193+ # - on master
194+ # - on release branches
195+ # - when PR has `ci-skip-cache` label
196+ if : |
197+ needs.job_get_metadata.outputs.is_master == 'false' &&
198+ needs.job_get_metadata.outputs.is_release == 'false' &&
199+ needs.job_get_metadata.outputs.force_skip_cache == 'false'
200+ with :
201+ path : node_modules/.cache/nx
202+ key : nx-${{ runner.os }}-${{ github.ref }}-${{ env.HEAD_COMMIT }}
203+ # GH will use the first restore-key it finds that matches
204+ # So it will start by looking for one from the same branch, else take the newest one it can find elsewhere
205+ restore-keys : |
206+ nx-${{ runner.os }}-${{ github.ref }}-${{ env.HEAD_COMMIT }}
207+ nx-${{ runner.os }}-${{ github.ref }}
208+ nx-${{ runner.os }}
209+
177210 - name : Build packages
178211 # Under normal circumstances, using the git SHA as a cache key, there shouldn't ever be a cache hit on the built
179212 # packages, and so `yarn build` should always run. This `if` check is therefore only there for testing CI issues
@@ -232,7 +265,7 @@ jobs:
232265 timeout-minutes : 15
233266 runs-on : ubuntu-20.04
234267 # Size Check will error out outside of the context of a PR
235- if : github.event_name == 'pull_request' || github.ref == 'refs/heads/master '
268+ if : github.event_name == 'pull_request' || needs.job_get_metadata.outputs.is_master == 'true '
236269 steps :
237270 - name : Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
238271 uses : actions/checkout@v3
@@ -258,7 +291,7 @@ jobs:
258291 - name : Check bundle sizes
259292 uses : getsentry/size-limit-action@v5
260293 # Don't run size check on release branches - at that point, we're already committed
261- if : ${{ !startsWith(github.ref, 'refs/heads/release/') }}
294+ if : needs.job_get_metadata.outputs.is_release == 'false'
262295 with :
263296 github_token : ${{ secrets.GITHUB_TOKEN }}
264297 skip_step : build
@@ -320,7 +353,7 @@ jobs:
320353 needs : [job_get_metadata, job_build]
321354 runs-on : ubuntu-20.04
322355 # Build artifacts are only needed for releasing workflow.
323- if : startsWith(github.ref, 'refs/heads/release/')
356+ if : needs.job_get_metadata.outputs.is_release == 'true'
324357 steps :
325358 - name : Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
326359 uses : actions/checkout@v3
@@ -339,7 +372,7 @@ jobs:
339372 path : ${{ env.CACHED_BUILD_PATHS }}
340373 key : ${{ env.BUILD_CACHE_KEY }}
341374 - name : Pack
342- run : yarn build:npm
375+ run : yarn build:tarball
343376 - name : Archive artifacts
344377345378 with :
0 commit comments