Skip to content

Commit a17f4f9

Browse files
committed
ci: Skip dependency cache when using label
1 parent 03a1205 commit a17f4f9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,18 @@ jobs:
143143
- name: Compute dependency cache key
144144
id: compute_lockfile_hash
145145
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
146148
- name: Check dependency cache
147149
uses: actions/cache@v3
148150
id: cache_dependencies
151+
if: needs.job_get_metadata.outputs.force_skip_cache == false
149152
with:
150153
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
151154
key: ${{ steps.compute_lockfile_hash.outputs.hash }}
155+
152156
- name: Install dependencies
153-
if: steps.cache_dependencies.outputs.cache-hit == ''
157+
if: steps.cache_dependencies.outputs.cache-hit == '' || needs.job_get_metadata.outputs.force_skip_cache
154158
run: yarn install --ignore-engines --frozen-lockfile
155159
outputs:
156160
dependency_cache_key: ${{ steps.compute_lockfile_hash.outputs.hash }}
@@ -185,7 +189,10 @@ jobs:
185189
# - on master
186190
# - on release branches
187191
# - when PR has `ci-skip-cache` label
188-
if: github.ref != 'refs/heads/master' && startsWith(github.ref, 'refs/heads/release/') == false
192+
if: |
193+
needs.job_get_metadata.outputs.is_master == false &&
194+
needs.job_get_metadata.outputs.is_release == false &&
195+
needs.job_get_metadata.outputs.force_skip_cache == false
189196
with:
190197
path: node_modules/.cache/nx
191198
key: nx-${{ runner.os }}-${{ github.ref }}-${{ env.HEAD_COMMIT }}
@@ -254,7 +261,7 @@ jobs:
254261
timeout-minutes: 15
255262
runs-on: ubuntu-20.04
256263
# Size Check will error out outside of the context of a PR
257-
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
264+
if: github.event_name == 'pull_request' || needs.job_get_metadata.outputs.is_master
258265
steps:
259266
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
260267
uses: actions/checkout@v3
@@ -280,7 +287,7 @@ jobs:
280287
- name: Check bundle sizes
281288
uses: getsentry/size-limit-action@v5
282289
# Don't run size check on release branches - at that point, we're already committed
283-
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
290+
if: needs.job_get_metadata.outputs.is_release == false
284291
with:
285292
github_token: ${{ secrets.GITHUB_TOKEN }}
286293
skip_step: build
@@ -342,7 +349,7 @@ jobs:
342349
needs: [job_get_metadata, job_build]
343350
runs-on: ubuntu-20.04
344351
# Build artifacts are only needed for releasing workflow.
345-
if: startsWith(github.ref, 'refs/heads/release/')
352+
if: needs.job_get_metadata.outputs.is_release
346353
steps:
347354
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
348355
uses: actions/checkout@v3

0 commit comments

Comments
 (0)