summaryrefslogtreecommitdiff
path: root/.github/workflows/codeql-analysis.yml
blob: 7176702ee46fdbfaa58383a5bb29ffbe8ecb23c3 (plain)
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
# This workflow helps to analyze repository code for vulnerabilities, bugs, and other errors using CodeQL. 
# For that CodeQL Action is used: https://github.com/github/codeql-action
# Learn more about CodeQL at https://codeql.github.com/

name: CodeQL

on:
  workflow_call:
    inputs:
      languages:
        description: "Optional input to set languages for CodeQL check. Supported values are: 'cpp', 'csharp', 'go', 'java', 'javascript', 'typescript', 'python', 'ruby'. To set multiple languages, use the same syntax as you can see in the default value."
        required: false
        type: string
        default: "['python']"
      codeql-cfg-path:
        description: "Optional input to set path to a CodeQL config file"
        required: false
        type: string
      build-command:
        description: "Optional input to specify manual build command. The multiline syntax is supported"
        required: false
        type: string

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write

    strategy:
      fail-fast: false
      matrix:
        language: ${{fromJson(inputs.languages)}}

    steps:
    - name: Checkout
      uses: actions/checkout@v4

    # Initializes the CodeQL tools for scanning.
    - name: Initialize CodeQL
      uses: github/codeql-action/init@v3
      with:
        languages: ${{matrix.language}}
        config-file: ${{inputs.codeql-cfg-path}}

    # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).
    # If this step fails, configure a build command manually using build-command input. This command will be executed in the corresponding step.
    - name: Autobuild
      if: ${{!inputs.build-command}}
      uses: github/codeql-action/autobuild@v3

    - name: Manual build
      if: ${{inputs.build-command}}
      run: |
        ${{inputs.build-command}}

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v3