name: "CodeQL"

on:
  pull_request:
  schedule:
    # run weekly new vulnerability was added to the database
    - cron: '0 3 * * 0'

concurrency:
  group: codeql-${{ github.head_ref || github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-latest
    if: github.event_name != 'schedule' || github.repository == 'valkey-io/valkey'
    permissions:
      security-events: write

    strategy:
      fail-fast: false
      matrix:
        language: ['cpp']

    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Initialize CodeQL
        uses: github/codeql-action/init@b5ebac6f4c00c8ccddb7cdcd45fdb248329f808a # v3.32.2
        with:
          languages: ${{ matrix.language }}

      - name: Autobuild
        uses: github/codeql-action/autobuild@b5ebac6f4c00c8ccddb7cdcd45fdb248329f808a # v3.32.2

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@b5ebac6f4c00c8ccddb7cdcd45fdb248329f808a # v3.32.2
