name: "CodeQL JavaScript"

on:
  push:
    branches: [ "master" ]
    paths:
      - '**/*.js' # Only trigger the workflow if JavaScript files have changed
  pull_request:
    branches: [ "master" ]
    paths:
      - '**/*.js'

jobs:
  analyze:
    if: github.repository == 'OpenRefine/OpenRefine'
    name: Analyze JavaScript
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v5

      - name: Initialize CodeQL
        uses: github/codeql-action/init@v3
        with:
          languages: 'javascript'

      - name: Build
        run: |
          ./refine build

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v3
        with:
          category: "/language:javascript"
