@@ -120,6 +120,10 @@ 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+ is_master : ${{ github.ref == 'refs/heads/master' }}
124+ is_release : ${{ startsWith(github.ref, 'refs/heads/release/') }}
125+ force_skip_cache :
126+ ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci-skip-cache') }}
123127
124128 job_install_deps :
125129 name : Install Dependencies
@@ -139,14 +143,19 @@ jobs:
139143 - name : Compute dependency cache key
140144 id : compute_lockfile_hash
141145 run : echo "hash=${{ hashFiles('yarn.lock') }}" >> "$GITHUB_OUTPUT"
146+
147+ # When the `ci-skip-cache` label is added to a PR, we always want to skip dependency cache
142148 - name : Check dependency cache
143149 uses : actions/cache@v3
144150 id : cache_dependencies
151+ if : needs.job_get_metadata.outputs.force_skip_cache == 'false'
145152 with :
146153 path : ${{ env.CACHED_DEPENDENCY_PATHS }}
147154 key : ${{ steps.compute_lockfile_hash.outputs.hash }}
155+
148156 - name : Install dependencies
149- if : steps.cache_dependencies.outputs.cache-hit == ''
157+ if :
158+ steps.cache_dependencies.outputs.cache-hit == '' || needs.job_get_metadata.outputs.force_skip_cache == 'true'
150159 run : yarn install --ignore-engines --frozen-lockfile
151160 outputs :
152161 dependency_cache_key : ${{ steps.compute_lockfile_hash.outputs.hash }}
@@ -174,6 +183,27 @@ jobs:
174183 with :
175184 path : ${{ env.CACHED_BUILD_PATHS }}
176185 key : ${{ env.BUILD_CACHE_KEY }}
186+
187+ - name : NX cache
188+ uses : actions/cache@v3
189+ # Disable cache when:
190+ # - on master
191+ # - on release branches
192+ # - when PR has `ci-skip-cache` label
193+ if : |
194+ needs.job_get_metadata.outputs.is_master == 'false' &&
195+ needs.job_get_metadata.outputs.is_release == 'false' &&
196+ needs.job_get_metadata.outputs.force_skip_cache == 'false'
197+ with :
198+ path : node_modules/.cache/nx
199+ key : nx-${{ runner.os }}-${{ github.ref }}-${{ env.HEAD_COMMIT }}
200+ # GH will use the first restore-key it finds that matches
201+ # So it will start by looking for one from the same branch, else take the newest one it can find elsewhere
202+ restore-keys : |
203+ nx-${{ runner.os }}-${{ github.ref }}-${{ env.HEAD_COMMIT }}
204+ nx-${{ runner.os }}-${{ github.ref }}
205+ nx-${{ runner.os }}
206+
177207 - name : Build packages
178208 # Under normal circumstances, using the git SHA as a cache key, there shouldn't ever be a cache hit on the built
179209 # packages, and so `yarn build` should always run. This `if` check is therefore only there for testing CI issues
@@ -232,7 +262,7 @@ jobs:
232262 timeout-minutes : 15
233263 runs-on : ubuntu-20.04
234264 # Size Check will error out outside of the context of a PR
235- if : github.event_name == 'pull_request' || github.ref == 'refs/heads/master '
265+ if : github.event_name == 'pull_request' || needs.job_get_metadata.outputs.is_master == 'true '
236266 steps :
237267 - name : Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
238268 uses : actions/checkout@v3
@@ -258,7 +288,7 @@ jobs:
258288 - name : Check bundle sizes
259289 uses : getsentry/size-limit-action@v5
260290 # Don't run size check on release branches - at that point, we're already committed
261- if : ${{ !startsWith(github.ref, 'refs/heads/release/') }}
291+ if : needs.job_get_metadata.outputs.is_release == false
262292 with :
263293 github_token : ${{ secrets.GITHUB_TOKEN }}
264294 skip_step : build
@@ -320,7 +350,7 @@ jobs:
320350 needs : [job_get_metadata, job_build]
321351 runs-on : ubuntu-20.04
322352 # Build artifacts are only needed for releasing workflow.
323- if : startsWith(github.ref, 'refs/heads/release/')
353+ if : needs.job_get_metadata.outputs.is_release
324354 steps :
325355 - name : Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
326356 uses : actions/checkout@v3
@@ -339,7 +369,7 @@ jobs:
339369 path : ${{ env.CACHED_BUILD_PATHS }}
340370 key : ${{ env.BUILD_CACHE_KEY }}
341371 - name : Pack
342- run : yarn build:npm
372+ run : yarn build:tarball
343373 - name : Archive artifacts
344374345375 with :
0 commit comments