Skip to content

Commit c4d328a

Browse files
committed
fix: add advanced codeql configuration that triggers for pull requests from forks
Signed-off-by: Fabian Burth <fabian.burth@sap.com>
1 parent d3ae8c9 commit c4d328a

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

.github/workflows/codeql.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request_target:
7+
branches: [main]
8+
schedule:
9+
# Run weekly on Monday at 07:25 UTC
10+
- cron: "25 7 * * 1"
11+
12+
# For pull_request_target events, check out the fork's code.
13+
# Falls back to the current repository/ref for push and schedule events.
14+
env:
15+
REF: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.ref || github.ref }}
16+
REPO: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name || github.repository }}
17+
18+
# Top-level permissions: restrict to read-only by default.
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
analyze:
24+
name: Analyze (${{ matrix.language }})
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 360
27+
permissions:
28+
# Required to upload CodeQL results to the Security tab.
29+
security-events: write
30+
# Required to check out the repository.
31+
contents: read
32+
# Required for workflows in private repositories.
33+
actions: read
34+
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
include:
39+
- language: go
40+
- language: actions
41+
42+
env:
43+
# This repository uses CGO (github.com/miekg/pkcs11).
44+
CGO_ENABLED: 1
45+
46+
steps:
47+
- name: Checkout repository
48+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
49+
with:
50+
repository: ${{ env.REPO }}
51+
ref: ${{ env.REF }}
52+
53+
- name: Initialize CodeQL
54+
uses: github/codeql-action/init@45580472a5bb82c4681c4ac726cfdb60060c2ee1 # v3
55+
with:
56+
languages: ${{ matrix.language }}
57+
queries: security-extended
58+
59+
- name: Autobuild
60+
if: matrix.language == 'go'
61+
uses: github/codeql-action/autobuild@45580472a5bb82c4681c4ac726cfdb60060c2ee1 # v3
62+
63+
- name: Perform CodeQL Analysis
64+
uses: github/codeql-action/analyze@45580472a5bb82c4681c4ac726cfdb60060c2ee1 # v3
65+
with:
66+
category: "/language:${{ matrix.language }}"

0 commit comments

Comments
 (0)