name: GitHub CodeQL 🔬

on:
  workflow_call:
    inputs:
      commit:
        required: true
        type: string

jobs:
  analyze:
    name: Analyze ${{ matrix.language }} 🔬
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        language:
          - javascript-typescript

    steps:
      - name: Checkout repository ⬇️
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          ref: ${{ inputs.commit }}
          show-progress: false

      - name: Initialize CodeQL 🛠️
        uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
        with:
          queries: security-and-quality
          languages: ${{ matrix.language }}

      - name: Autobuild 📦
        uses: github/codeql-action/autobuild@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0

      - name: Perform CodeQL Analysis 🧪
        uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
        with:
          category: '/language:${{matrix.language}}'
