name: Code Scan

on:
  push:
    branches:
    - main
    - scan
  pull_request:
    branches:
    - main
    - scan

jobs:
  scan:
    name: Scan Codebase via CodeQL
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write

    strategy:
      fail-fast: false
      matrix:
        language:
        - cpp

    steps:
    - name: Install dependencies
      run: |
        sudo apt -y update
        sudo apt -y install dbus expat libaudit-dev libselinux-dev libsystemd-dev python3-pip
        sudo pip3 install meson ninja
    - name: Checkout repository
      uses: actions/checkout@v3
    - name: Initialize CodeQL
      uses: github/codeql-action/init@v2
      with:
        config-file: ./.github/codeql-config.yml
        languages: ${{ matrix.language }}
    - name: Automatically Build Project
      uses: github/codeql-action/autobuild@v2
    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v2
