Skip to content

Commit

Permalink
Skip sonar analysis for forks to avoid exposing secrets
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Carreras <leonardo.carreras@eonerc.rwth-aachen.de>
  • Loading branch information
leonardocarreras committed Dec 11, 2024
1 parent 01658ee commit d6d2a25
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/workflows/sonar_cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
sonarcloud:
name: Prepare and run Sonar Scan
runs-on: ubuntu-latest
if: secrets.SONAR_TOKEN != '' # Skip the job if SONAR_TOKEN is not set
container: sogno/dpsim:dev
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
Expand Down Expand Up @@ -53,4 +54,14 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json
sonar-scanner --define sonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json
notify-missing-token:
name: Notify Missing Sonar Token
runs-on: ubuntu-latest
needs: sonarcloud
if: ${{ needs.sonarcloud.result == 'skipped' }} # Run only if sonarcloud job was skipped
steps:
- name: Notify Missing Token
run: |
echo "SonarCloud analysis was skipped because the SONAR_TOKEN secret is not set. This is likely due to the origin repository being a fork."

0 comments on commit d6d2a25

Please sign in to comment.