name: "CodeQL"

permissions: read-all

on:
  push:
    branches: [ main ]
    paths:
      - '**.js'
      - '**.go'
      - '!**_test.go'
      - '.github/workflows/codeql-analysis.yml'
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [ main ]
    paths:
      - '**.js'
      - '**.go'
      - '!**_test.go'
      - '.github/workflows/codeql-analysis.yml'
  schedule:
    - cron: '45 22 * * 3'
  workflow_dispatch:

jobs:
  analyze:
    name: Analyze (${{ matrix.language }})
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write

    strategy:
      fail-fast: false
      matrix:
        language: [ 'go', 'javascript' ]

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

    - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
      if: matrix.language == 'go'
      with:
        go-version: stable

    - name: Initialize CodeQL
      uses: github/codeql-action/init@e46ed2cbd01164d986452f91f178727624ae40d7 # v4.35.3
      with:
        languages: ${{ matrix.language }}

    - name: Autobuild
      uses: github/codeql-action/autobuild@e46ed2cbd01164d986452f91f178727624ae40d7 # v4.35.3

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