Skip to content

Commit 82ce469

Browse files
committed
ci: skip the Code Scanning upload on pull requests from forks
1 parent d7a58d6 commit 82ce469

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ jobs:
207207
key: ${{ steps.resource-cache.outputs.cache-primary-key }}
208208

209209
- name: Upload SARIF to Code Scanning
210-
if: runner.os == 'Linux' && always() && hashFiles('artifacts/self-analysis.sarif') != ''
210+
# A pull request from a fork gets a read-only token, which Code Scanning refuses.
211+
if: runner.os == 'Linux' && always() && hashFiles('artifacts/self-analysis.sarif') != '' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
211212
uses: github/codeql-action/upload-sarif@v3
212213
with:
213214
sarif_file: artifacts/self-analysis.sarif

‎.github/workflows/concurrency.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,5 @@ jobs:
6060
with:
6161
compile-commands: build/compile_commands.json
6262
fail-on: error
63+
# A pull request from a fork gets a read-only token, which Code Scanning refuses.
64+
upload-sarif: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}

0 commit comments

Comments
 (0)