name: "CodeQL (Scheduled)"

# Schedule-only: weekly deep scan with latest CodeQL rules.
# Push/PR analysis is handled by the main ci.yml workflow.
on:
  schedule:
    - cron: '0 6 * * 1' # Weekly on Monday at 06:00 UTC

permissions:
  actions: read
  contents: read

jobs:
  analyze:
    name: CodeQL Analysis
    runs-on: ubuntu-latest
    permissions:
      security-events: write
      contents: read

    strategy:
      fail-fast: false
      matrix:
        language: [ java-kotlin ]

    steps:
      - name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

      - name: Set up JDK 25
        uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
        with:
          distribution: temurin
          java-version: '25'
          cache: maven

      - name: Initialize CodeQL
        uses: github/codeql-action/init@87557b9c84dde89fdd9b10e88954ac2f4248e463 # v4.36.1
        with:
          languages: ${{ matrix.language }}
          queries: security-extended

      - name: Set execute permission for mvnw
        run: chmod +x mvnw

      - name: Build
        run: ./mvnw clean compile -DskipTests -B --no-transfer-progress

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@87557b9c84dde89fdd9b10e88954ac2f4248e463 # v4.36.1
        with:
          category: "/language:${{ matrix.language }}"
