From ed2421b581fc31f0f21071c35f88b5d96044989b Mon Sep 17 00:00:00 2001 From: Beats Date: Sat, 24 Feb 2024 19:59:59 -0300 Subject: [PATCH] ci/cd: run sonarcloud only in the main branch (#2317) --- .github/workflows/analysis-sonarcloud.yml | 26 ++--------------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/.github/workflows/analysis-sonarcloud.yml b/.github/workflows/analysis-sonarcloud.yml index 1b75d085097..d742af72625 100644 --- a/.github/workflows/analysis-sonarcloud.yml +++ b/.github/workflows/analysis-sonarcloud.yml @@ -2,9 +2,8 @@ name: Analysis - SonarCloud on: - pull_request: - types: [opened, synchronize, reopened, ready_for_review] - branches-ignore: + push: + branches: - main paths: - "src/**" @@ -22,14 +21,6 @@ jobs: steps: - uses: actions/checkout@v3 - if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }} - with: - fetch-depth: 0 - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - - uses: actions/checkout@v3 - if: ${{ github.event_name == 'push' }} with: fetch-depth: 0 @@ -75,20 +66,7 @@ jobs: mkdir -p build cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -DOPTIONS_ENABLE_CCACHE=ON -DSPEED_UP_BUILD_UNITY=OFF -S . -B build - - name: Run PR sonar-scanner - if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: | - sonar-scanner \ - --define sonar.cfamily.compile-commands=build/compile_commands.json \ - --define sonar.pullrequest.key=${{ github.event.pull_request.number }} \ - --define sonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} \ - --define sonar.pullrequest.base=${{ github.event.pull_request.base_ref }} - - name: Run sonar-scanner - if: ${{ github.event_name == 'push' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}