name: Sonar CI
on:
  push:
    branches:
    - master
    - '[4-9]+.[0-9]+.x'
    - sonar

jobs:
  build:

    runs-on: ubuntu-latest
    if: ${{ github.repository_owner == 'OpenAPITools' }}
    steps:
    - uses: actions/checkout@v3
    - name: Set up JDK 11
      uses: actions/setup-java@v3
      with:
        distribution: 'temurin'
        java-version: 11
    - name: Compile with Maven
      run: ./mvnw -B -q clean install jacoco:report
    - name: Jacoco Aggregate
      run: ./mvnw jacoco:report-aggregate
    - name: Publish to Sonar
      run: ./mvnw -B -q -nsu sonar:sonar -Dsonar.projectKey=OpenAPITools_openapi-generator -Dsonar.organization=openapitools -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_LOGIN }} -Dsonar.branch.name=${GITHUB_REF##*/}
