-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (59 loc) · 2.36 KB
/
shared-codeql.yml
File metadata and controls
65 lines (59 loc) · 2.36 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
name: Shared CodeQL analysis
# CodeQL documentation https://github.com/github/codeql-action
# CodeQL supported languages https://codeql.github.com/docs/codeql-overview/supported-languages-and-frameworks
# Also see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#changing-the-languages-that-are-analyzed
on:
workflow_call:
inputs:
languages:
description: 'Languages to analyze (JSON array, e.g., ["actions"]). See supported languages at https://codeql.github.com/docs/codeql-overview/supported-languages-and-frameworks'
required: true
type: string
java_build_command:
description: "Optional build command for Java projects. Leave empty if not needed, build-mode: none is used."
required: false
type: string
default: ""
java_version:
description: "Optional Java version to set up (e.g. '21'). If not given, uses runner default."
required: false
type: string
default: ""
jobs:
analyze:
name: Analyze code
runs-on: ubuntu-24.04
permissions:
# required for all workflows
security-events: write
# required to fetch internal or private CodeQL packs
packages: read
# only required for workflows in private repositories
actions: read
# repository contents
contents: read
strategy:
fail-fast: false
matrix:
language: ${{ fromJSON(inputs.languages) }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Java
if: matrix.language == 'java-kotlin' && inputs.java_version != ''
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: ${{ inputs.java_version }}
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ (matrix.language == 'java-kotlin' && inputs.java_build_command != '') && 'manual' || 'none' }}
- name: Build Java project
if: matrix.language == 'java-kotlin' && inputs.java_build_command != ''
run: ${{ inputs.java_build_command }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"