@@ -3,29 +3,47 @@ name: CodeQL Security Analysis
33on :
44 push :
55 branches : [master]
6- paths :
7- # Only run when JEngine code changes
8- - ' UnityProject/Packages/com.jasonxudeveloper.jengine.core/**'
9- - ' UnityProject/Packages/com.jasonxudeveloper.jengine.util/**'
10- - ' UnityProject/Assets/HotUpdate/Code/**'
11- - ' .github/codeql/**'
12- - ' .github/workflows/codeql.yml'
6+ # Path filtering moved to job level for push events
137 pull_request :
148 branches : [master]
15- paths :
16- - ' UnityProject/Packages/com.jasonxudeveloper.jengine.core/**'
17- - ' UnityProject/Packages/com.jasonxudeveloper.jengine.util/**'
18- - ' UnityProject/Assets/HotUpdate/Code/**'
19- - ' .github/codeql/**'
20- - ' .github/workflows/codeql.yml'
9+ # Path filtering moved to job level using dorny/paths-filter
10+ # This ensures the workflow always runs and reports a status
2111 schedule :
2212 # Run weekly on Sunday at 00:00 UTC
2313 - cron : ' 0 0 * * 0'
2414 workflow_dispatch :
2515
2616jobs :
17+ changes :
18+ name : Detect Changes
19+ runs-on : ubuntu-latest
20+ # Only run path detection for push/pull_request events
21+ if : github.event_name == 'push' || github.event_name == 'pull_request'
22+ outputs :
23+ should_analyze : ${{ steps.filter.outputs.src }}
24+ steps :
25+ - uses : actions/checkout@v4
26+ - uses : dorny/paths-filter@v3
27+ id : filter
28+ with :
29+ filters : |
30+ src:
31+ - 'UnityProject/Packages/com.jasonxudeveloper.jengine.core/**'
32+ - 'UnityProject/Packages/com.jasonxudeveloper.jengine.util/**'
33+ - 'UnityProject/Assets/HotUpdate/Code/**'
34+ - '.github/codeql/**'
35+ - '.github/workflows/codeql.yml'
36+
2737 analyze :
2838 name : Analyze C# Code
39+ needs : changes
40+ # Run if: 1) changes detected, 2) schedule event, or 3) manual dispatch
41+ if : |
42+ always() && (
43+ needs.changes.outputs.should_analyze == 'true' ||
44+ github.event_name == 'schedule' ||
45+ github.event_name == 'workflow_dispatch'
46+ )
2947 runs-on : ubuntu-latest
3048 permissions :
3149 actions : read
5068 uses : github/codeql-action/analyze@v4
5169 with :
5270 category : " /language:csharp"
71+
72+ skip-analyze :
73+ name : Analyze C# Code
74+ needs : changes
75+ # Only skip for push/pull_request when no relevant changes
76+ if : |
77+ always() &&
78+ (github.event_name == 'push' || github.event_name == 'pull_request') &&
79+ needs.changes.outputs.should_analyze == 'false'
80+ runs-on : ubuntu-latest
81+ steps :
82+ - name : Skip analysis
83+ run : echo "No relevant changes detected, skipping CodeQL analysis"
0 commit comments