SonarCloud detecting PRs but not changed files in a PR

I am using SonarCloud in a private Java & Scala based maven project in a Github Repo.

My Github Actions workflow file is like below

name: Pull-Request Checks

on:
  pull_request:
  workflow_dispatch:
    inputs:
      branch:
        type: string
        description: The branch, tag or SHA to checkout
        required: true
  schedule:
    - cron: '0 */6 * * *'  # Runs every 6 hours on default branch, main

jobs:

  Unit-Tests:
    runs-on: nexla-dind-runners
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }}

      - name: Code Artifact Login
        uses: nexla/cloud-actions/actions/code-artifact-login@v1

      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: 17
          distribution: corretto

      - uses: sdkman/sdkman-action@master
        id: sdkman
        with:
          candidate: scala
          version: 2.12.18

      - name: Set up Maven
        uses: stCarolas/setup-maven@v5
        with:
          maven-version: 3.9.9

      - name: Restore Maven cache
        uses: actions/cache@v4
        with:
          path: |
            ~/.m2/repository
          key: maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            maven-

      - name: Build with Maven
        env:
          MAVEN_OPTS: -Xmx8g -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/root/.m2/heapdump
        shell: bash
        run: |
          echo "Running unit tests"
          mvn clean install -T 1 -Dsonar.skip=true --settings .mvn/local-settings.xml --no-transfer-progress

      - name: Display JaCoCo XML Report
        run: |
          echo "Printing JaCoCo aggregate XML report"
          cat coverage/target/site/jacoco-aggregate/jacoco.xml

      - name: Fetch base branch
        if: github.event_name == 'pull_request'
        run: git fetch origin ${{ github.event.pull_request.base.ref }}

      - name: Analyze on SonarCloud
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        run: |
          if [[ "${{ github.event_name }}" == "pull_request" ]]; then
            mvn sonar:sonar --settings .mvn/local-settings.xml \
              -Dsonar.log.level=INFO \
              -Dorg.slf4j.simpleLogger.log.org.sonarsource.scanner.lib.internal.facade.forked.ScannerEngineLauncher=INFO \
              -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }} \
              -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} \
              -Dsonar.host.url=https://sonarcloud.io \
              -Dsonar.login=${{ secrets.SONAR_TOKEN }} \
              -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} \
              -Dsonar.pullrequest.branch=${{ github.head_ref }} \
              -Dsonar.pullrequest.base=${{ github.base_ref }} \
              -Dsonar.coverage.jacoco.xmlReportPaths=${{ github.workspace }}/coverage/target/site/jacoco-aggregate/jacoco.xml
          else
            mvn sonar:sonar --settings .mvn/local-settings.xml \
              -Dsonar.log.level=INFO \
              -Dorg.slf4j.simpleLogger.log.org.sonarsource.scanner.lib.internal.facade.forked.ScannerEngineLauncher=INFO \
              -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }} \
              -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} \
              -Dsonar.host.url=https://sonarcloud.io \
              -Dsonar.login=${{ secrets.SONAR_TOKEN }} \
              -Dsonar.coverage.jacoco.xmlReportPaths=${{ github.workspace }}/coverage/target/site/jacoco-aggregate/jacoco.xml
          fi

I am observing that sonar is detecting PRs but not the changed files within the PR.

Automatic analysis is disabled

New Code is set to previous version.

Sonar Analysis logs are placed here.

Can someone let me know what is going wrong?

If I maven the command like below it is working. Can someone explain the reasoning behind this?

            mvn clean package sonar:sonar -T 3 --settings ./.mvn/local-settings.xml -T 1 --no-transfer-progress \
              -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }} \
              -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} \
              -Dsonar.host.url=https://sonarcloud.io \
              -Dsonar.login=${{ secrets.SONAR_TOKEN }} \
              -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} \
              -Dsonar.pullrequest.branch=${{ github.head_ref }} \
              -Dsonar.pullrequest.base=${{ github.base_ref }}
          else
            mvn clean package sonar:sonar -T 3 --settings ./.mvn/local-settings.xml -T 1 --no-transfer-progress \
              -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }} \
              -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} \
              -Dsonar.host.url=https://sonarcloud.io \
              -Dsonar.login=${{ secrets.SONAR_TOKEN }} 
          fi

Hey there.

In the logs you shared it shows that 0 files have been indexed.

[INFO] 0 files indexed (done) | time=33ms`

Can you share the logs from a working run? That might give some clues on what the difference is.