diff --git a/.github/workflows/sonar_cloud.yaml b/.github/workflows/sonar_cloud.yaml index 21b3bca11..c6e297618 100644 --- a/.github/workflows/sonar_cloud.yaml +++ b/.github/workflows/sonar_cloud.yaml @@ -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 @@ -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 \ No newline at end of file + 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." \ No newline at end of file