name: SonarQube Scan
on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  build:
    name: Sonar Code Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2.4.0
        with:
          fetch-depth: 0
      - uses: sonarsource/sonarqube-scan-action@master
        with:
          args: >
            -Dsonar.projectKey=propertyguru_${{ github.event.repository.name }}
            -Dsonar.projectName=propertyguru_${{ github.event.repository.name }}
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
      - uses: sonarsource/sonarqube-quality-gate-action@master
        timeout-minutes: 5
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
