Skip to content

Commit 2932e84

Browse files
authored
chore(ci): only save cargo registry cache from master (#25643)
1 parent 3dbc4f4 commit 2932e84

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

.github/actions/setup/action.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,11 @@ runs:
134134
run: echo "::add-matcher::.github/matchers/rust.json"
135135
shell: bash
136136

137+
# Two steps so that the actions/cache post-step (which saves the cache) runs
138+
# directly from this composite, not a nested one — nested composites break
139+
# post-step input resolution (actions/runner#3514, #2030).
137140
- name: Cache Cargo registry, index, and git DB
138-
if: ${{ inputs.cargo-cache == 'true' || env.NEEDS_RUST == 'true' }}
141+
if: ${{ (inputs.cargo-cache == 'true' || env.NEEDS_RUST == 'true') && github.ref == 'refs/heads/master' }}
139142
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
140143
with:
141144
path: |
@@ -146,6 +149,18 @@ runs:
146149
restore-keys: |
147150
${{ runner.os }}-cargo-
148151
152+
- name: Restore Cargo registry, index, and git DB
153+
if: ${{ (inputs.cargo-cache == 'true' || env.NEEDS_RUST == 'true') && github.ref != 'refs/heads/master' }}
154+
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
155+
with:
156+
path: |
157+
~/.cargo/registry/index/
158+
~/.cargo/registry/cache/
159+
~/.cargo/git/db/
160+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
161+
restore-keys: |
162+
${{ runner.os }}-cargo-
163+
149164
- name: Install mold
150165
if: ${{ runner.os == 'Linux' && env.DISABLE_MOLD != 'true' && inputs.mold == 'true' }}
151166
shell: bash

0 commit comments

Comments
 (0)