-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (100 loc) · 2.77 KB
/
Copy pathcodeql.yml
File metadata and controls
111 lines (100 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: CodeQL
on:
push:
branches:
- main
- master
- develop
- staging
- production
pull_request:
branches:
- main
- master
- develop
- staging
- production
schedule:
- cron: "0 8 * * 1"
workflow_dispatch:
permissions:
contents: read
security-events: write
actions: read
concurrency:
group: codeql-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
analyze:
name: Analyze code with CodeQL
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
language:
- javascript-typescript
- python
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Detect JavaScript and TypeScript files
id: detect-js-ts
if: ${{ matrix.language == 'javascript-typescript' }}
shell: bash
run: |
if find . \
-path "./.git" -prune -o \
-type f \( \
-name "*.js" -o \
-name "*.jsx" -o \
-name "*.ts" -o \
-name "*.tsx" -o \
-name "*.mjs" -o \
-name "*.cjs" \
\) -print -quit | grep -q .; then
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
fi
- name: Detect Python files
id: detect-python
if: ${{ matrix.language == 'python' }}
shell: bash
run: |
if find . \
-path "./.git" -prune -o \
-type f -name "*.py" -print -quit | grep -q .; then
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
fi
- name: Initialize CodeQL
if: >-
${{
steps.detect-js-ts.outputs.found == 'true' ||
steps.detect-python.outputs.found == 'true'
}}
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: security-extended,security-and-quality
- name: Perform CodeQL analysis
if: >-
${{
steps.detect-js-ts.outputs.found == 'true' ||
steps.detect-python.outputs.found == 'true'
}}
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{ matrix.language }}"
- name: Skip analysis when language is not detected
if: >-
${{
steps.detect-js-ts.outputs.found == 'false' ||
steps.detect-python.outputs.found == 'false'
}}
shell: bash
run: |
echo "No files detected for language: ${{ matrix.language }}."
echo "Skipping CodeQL analysis for this language."