-
Notifications
You must be signed in to change notification settings - Fork 3
127 lines (105 loc) · 3.43 KB
/
Copy pathcodeql.yml
File metadata and controls
127 lines (105 loc) · 3.43 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: CodeQL code analysis
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
security-events: write
actions: read
contents: read
pull-requests: read
on:
push:
branches: ["main"]
paths-ignore:
- "docs/**"
- "**/*.md"
pull_request:
branches: ["main"]
paths-ignore:
- "docs/**"
- "**/*.md"
schedule:
- cron: "0 0 * * 0" # runs every week on Sunday at 00:00
jobs:
prepare-matrix:
name: Prepare matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Check for changed paths
uses: dorny/paths-filter@v4
id: filter
with:
filters: |
actions:
- '.github/**'
server:
- 'server/**'
client:
- 'client/**'
- name: Build matrix
id: set-matrix
run: |
matrix=$(jq -nc '{include: []}')
if [[ "${{ github.event_name }}" == "schedule" ]] || [[ "${{ steps.filter.outputs.actions }}" == "true" ]]
then
matrix=$(echo "$matrix" | jq -c '.include += [{"language":"actions","build-mode":"none","path":".github"}]')
fi
if [[ "${{ github.event_name }}" == "schedule" ]] || [[ "${{ steps.filter.outputs.server }}" == "true" ]]
then
matrix=$(echo "$matrix" | jq -c '.include += [{"language":"csharp","build-mode":"none","path":"server"}]')
fi
if [[ "${{ github.event_name }}" == "schedule" ]] || [[ "${{ steps.filter.outputs.client }}" == "true" ]]
then
matrix=$(echo "$matrix" | jq -c '.include += [{"language":"javascript-typescript","build-mode":"none","path":"client"}]')
fi
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
analyze:
needs: prepare-matrix
if: ${{ fromJson(needs.prepare-matrix.outputs.matrix).include[0] != null }}
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
queries: +security-extended
config: |
paths:
- ${{ matrix.path }}/**
paths-ignore:
- '**/*.md'
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"
analysis-status:
name: Analysis status
needs: [prepare-matrix, analyze]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check analysis status
run: |
if [[ "${{ needs.prepare-matrix.result }}" == "failure" || "${{ needs.prepare-matrix.result }}" == "cancelled" ]]
then
echo "Failed to prepare the matrix."
exit 1
fi
if [[ "${{ needs.analyze.result }}" == "failure" || "${{ needs.analyze.result }}" == "cancelled" ]]
then
echo "Analyze job has been cancelled or failed."
exit 1
fi
echo "All jobs passed or were skipped."
exit 0