name: "CodeQL Java"

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

jobs:
  analyze:
    if: github.repository == 'OpenRefine/OpenRefine'
    name: Analyze Java
    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: 'java'

      - name: Build
        run: |
          ./refine build

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