Skip to content

Commit

Permalink
ci/cd: run sonarcloud only in the main branch (opentibiabr#2317)
Browse files Browse the repository at this point in the history
  • Loading branch information
beats-dh authored Feb 24, 2024
1 parent 5639c1b commit ed2421b
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions .github/workflows/analysis-sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
name: Analysis - SonarCloud

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches-ignore:
push:
branches:
- main
paths:
- "src/**"
Expand All @@ -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

Expand Down Expand Up @@ -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 }}
Expand Down

0 comments on commit ed2421b

Please sign in to comment.