|
40 | 40 |
|
41 | 41 | BUILD_CACHE_KEY: ${{ github.event.inputs.commit || github.sha }} |
42 | 42 |
|
| 43 | + # GH will use the first restore-key it finds that matches |
| 44 | + # So it will start by looking for one from the same branch, else take the newest one it can find elsewhere |
| 45 | + # We want to prefer the cache from the current master branch, if we don't find any on the current branch |
| 46 | + NX_CACHE_RESTORE_KEYS: | |
| 47 | + nx-Linux-${{ github.ref }}-${{ github.event.inputs.commit || github.sha }} |
| 48 | + nx-Linux-${{ github.ref }} |
| 49 | + nx-Linux-refs/heads/master |
| 50 | + nx-Linux |
| 51 | +
|
43 | 52 | jobs: |
44 | 53 | job_get_metadata: |
45 | 54 | name: Get Metadata |
@@ -194,18 +203,14 @@ jobs: |
194 | 203 | # - on release branches |
195 | 204 | # - when PR has `ci-skip-cache` label |
196 | 205 | if: | |
197 | | - needs.job_get_metadata.outputs.is_master == 'false' && |
198 | 206 | needs.job_get_metadata.outputs.is_release == 'false' && |
199 | 207 | needs.job_get_metadata.outputs.force_skip_cache == 'false' |
200 | 208 | with: |
201 | 209 | 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 }} |
| 210 | + key: nx-Linux-${{ github.ref }}-${{ env.HEAD_COMMIT }} |
| 211 | + # On master branch, we want to _store_ the cache (so it can be used by other branches), but never _restore_ from it |
| 212 | + restore-keys: |
| 213 | + ${{needs.job_get_metadata.outputs.is_master == 'false' && env.NX_CACHE_RESTORE_KEYS || 'nx-never-restore'}} |
209 | 214 |
|
210 | 215 | - name: Build packages |
211 | 216 | # Under normal circumstances, using the git SHA as a cache key, there shouldn't ever be a cache hit on the built |
|
0 commit comments