Skip to content

Commit 5549912

Browse files
committed
fix(ci): add CodeQL workflow for fork pull requests
GitHub's default CodeQL setup only runs on PRs from the same repository. Fork PRs (like #72) are skipped because pull_request events from forks don't have write access to the base repo's security events. Add an explicit codeql.yml workflow using pull_request_target so CodeQL analysis runs for both fork and non-fork PRs. The workflow checks out the PR head SHA explicitly while keeping permissions minimal (security-events: write, contents: read only).
1 parent bf32bf1 commit 5549912

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CodeQL
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request_target:
7+
branches: [main]
8+
schedule:
9+
- cron: "0 6 * * 1"
10+
11+
permissions: {}
12+
13+
jobs:
14+
analyze:
15+
name: Analyze (${{ matrix.language }})
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 30
18+
permissions:
19+
security-events: write
20+
contents: read
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
language: [actions, rust]
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
ref: ${{ github.event.pull_request.head.sha }}
29+
30+
- name: Initialize CodeQL
31+
uses: github/codeql-action/init@v3
32+
with:
33+
languages: ${{ matrix.language }}
34+
queries: security-extended
35+
36+
- name: Autobuild
37+
uses: github/codeql-action/autobuild@v3
38+
39+
- name: Perform CodeQL Analysis
40+
uses: github/codeql-action/analyze@v3
41+
with:
42+
category: "/language:${{ matrix.language }}"

0 commit comments

Comments
 (0)