name: build

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ ubuntu-latest, windows-latest, macos-latest ]
        java: [ '11' ]
    steps:
    - name: Checkout GitHub repo
      uses: actions/checkout@v2
    - name: Set up Java
      uses: actions/setup-java@v2
      with:
        distribution: 'adopt'
        java-version: ${{ matrix.java }}
    - name: Start Xvfb
      run: Xvfb :99 &
    - name: Run tests
      run: mvn -B test
      env:
        DISPLAY: :99
        WDM_GITHUBTOKENNAME: ${{ secrets.WDM_GITHUBTOKENNAME }}
        WDM_GITHUBTOKENSECRET: ${{ secrets.WDM_GITHUBTOKENSECRET }}
    - name: Upload analysis to SonarCloud
      if: success() && matrix.os == 'ubuntu-latest'
      run: >
        mvn -B sonar:sonar
        -Dsonar.host.url=https://sonarcloud.io
        -Dsonar.organization=bonigarcia-github
        -Dsonar.projectKey=io.github.bonigarcia:webdrivermanager
      env:
        GITHUB_TOKEN: ${{ secrets.WDM_GITHUBTOKENSECRET }}
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
    - name: Upload coverage to Codecov
      if: success() && matrix.os == 'ubuntu-latest'
      uses: codecov/codecov-action@v1

name: build

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ ubuntu-latest, windows-latest, macos-latest ]
        java: [ '11' ]
    steps:
    - name: Checkout GitHub repo
      uses: actions/checkout@v2
    - name: Set up Java
      uses: actions/setup-java@v2
      with:
        distribution: 'adopt'
        java-version: ${{ matrix.java }}
    - name: Start Xvfb
      run: Xvfb :99 &
    - name: Run tests
      run: mvn -B test
      env:
        DISPLAY: :99
        WDM_GITHUBTOKENNAME: ${{ secrets.WDM_GITHUBTOKENNAME }}
        WDM_GITHUBTOKENSECRET: ${{ secrets.WDM_GITHUBTOKENSECRET }}
    - name: Upload analysis to SonarCloud
      if: success() && matrix.os == 'ubuntu-latest' && matrix.os == '11' && "!${{contains(github.ref, 'pull')}}"
      run: >
        mvn -B sonar:sonar
        -Dsonar.host.url=https://sonarcloud.io
        -Dsonar.organization=bonigarcia-github
        -Dsonar.projectKey=io.github.bonigarcia:webdrivermanager
      env:
        GITHUB_TOKEN: ${{ secrets.WDM_GITHUBTOKENSECRET }}
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
    - name: Upload coverage to Codecov
      if: success() && matrix.os == 'ubuntu-latest'
      uses: codecov/codecov-action@v1

Enhance condition to upload analysis to SonarCloud in workflow setup
Enhance condition to upload analysis to SonarCloud in workflow setup
