Skip to content

Commit d40de47

Browse files
committed
Stop saving GitHub cache on pull requests
We should only save on pushes to main and other branches, and restore only in pull requests. Currently, pull request runs pollute the cache.
1 parent b0f8947 commit d40de47

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

.github/workflows/validate-apis.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ jobs:
4141
with:
4242
node-version: 22
4343

44-
- name: Cache JSON report
45-
id: cache-json-report
46-
uses: actions/cache@v4
44+
- name: Restore JSON report
45+
if: github.event_name == 'pull_request'
46+
uses: actions/cache/restore@v4
4747
with:
4848
path: ./clients-flight-recorder/recordings/types-validation/types-validation.json
49-
key: types-validation-json-${{ github.event_name == 'pull_request' && format('{0}-{1}', github.base_ref, github.event.pull_request.base.sha) || format('{0}-{1}', github.ref_name, github.sha) }}
49+
key: types-validation-json-${{ format('{0}-{1}', github.base_ref, github.event.pull_request.base.sha) }}
5050
restore-keys: |
51-
types-validation-json-${{ github.event_name == 'pull_request' && github.base_ref || github.ref_name }}-
51+
types-validation-json-${{ github.base_ref }}-
5252
5353
- name: Install deps 1/2
5454
working-directory: ./clients-flight-recorder
@@ -87,6 +87,15 @@ jobs:
8787
BRANCH: ${{ github.ref_name }}
8888
run: node index.js --generate-report --ci --branch $BRANCH
8989

90+
- name: Save JSON report
91+
if: github.event_name == 'push'
92+
uses: actions/cache/save@v4
93+
with:
94+
path: ./clients-flight-recorder/recordings/types-validation/types-validation.json
95+
key: types-validation-json-${{ format('{0}-{1}', github.ref_name, github.sha) }}
96+
restore-keys: |
97+
types-validation-json-${{ github.ref_name }}-
98+
9099
- name: Run validation (PR)
91100
if: github.event_name == 'pull_request'
92101
id: validation

0 commit comments

Comments
 (0)