Skip to content

Commit fa7a30f

Browse files
authored
ci: only use schema caching in action linting if not on a fork (#1178)
Forks do not get `actions: write` and so we cannot clear caches in those situations. To prevent inconsistencies we need to disable the whole schema caching functionality in this scenario.
1 parent fd77b75 commit fa7a30f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

.github/workflows/lint-shared-workflows.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
5151
- name: Restore github-action.json schema
5252
id: restore-schema
53+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
5354
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
5455
with:
5556
path: |
@@ -89,7 +90,7 @@ jobs:
8990
# Caches can't be overwritten, so we need to delete the previous cache if
9091
# the schema has changed
9192
- name: Delete Previous Cache
92-
if: steps.restore-schema.outputs.cache-hit == 'true' && steps.download-schema.outputs.schema-changed == 'true'
93+
if: steps.restore-schema.conclusion == 'success' && steps.restore-schema.outputs.cache-hit == 'true' && steps.download-schema.outputs.schema-changed == 'true'
9394
run: |
9495
gh extension install actions/gh-actions-cache
9596
gh actions-cache delete --repo "${{ github.repository }}" "github-action-schema" --confirm
@@ -98,7 +99,7 @@ jobs:
9899

99100
- name: Save github-action.json schema to cache
100101
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
101-
if: steps.download-schema.outputs.schema-changed == 'true'
102+
if: steps.restore-schema.conclusion == 'success' && steps.download-schema.outputs.schema-changed == 'true'
102103
with:
103104
path: |
104105
github-action.json

0 commit comments

Comments
 (0)