@@ -15,6 +15,11 @@ inputs:
1515 description : " Whether to fail the build if the quality gate fails"
1616 default : ' false'
1717
18+ outputs :
19+ sonar_report_url :
20+ description : " URL to the SonarCloud report for this branch"
21+ value : ${{ steps.report.outputs.url }}
22+
1823runs :
1924 using : " composite"
2025 steps :
3035 run : echo "secret_exist=${{ inputs.sonar_token != '' }}" >> $GITHUB_OUTPUT
3136 - name : " Perform static analysis"
3237 shell : bash
38+ id : sonar
3339 if : steps.check.outputs.secret_exist == 'true'
3440 continue-on-error : ${{ fromJSON(inputs.ignore_sonar_failure) }}
3541 env :
3945 run : |
4046 export BRANCH_NAME=${GITHUB_HEAD_REF:-$(echo $GITHUB_REF | sed 's#refs/heads/##')}
4147 ./scripts/reports/perform-static-analysis.sh
48+ - name : " Add SonarCloud report link to step summary"
49+ shell : bash
50+ id : report
51+ if : steps.sonar.outcome == 'success' || (steps.sonar.outcome == 'failure' && fromJSON(inputs.ignore_sonar_failure))
52+ env :
53+ SONAR_ORGANISATION_KEY : ${{ inputs.sonar_organisation_key }}
54+ SONAR_PROJECT_KEY : ${{ inputs.sonar_project_key }}
55+ run : |
56+ export BRANCH_NAME=${GITHUB_HEAD_REF:-$(echo $GITHUB_REF | sed 's#refs/heads/##')}
57+ ENCODED_BRANCH=$(echo "$BRANCH_NAME" | sed 's/\//%2F/g')
58+ SONAR_URL="https://sonarcloud.io/summary/overall?id=${SONAR_PROJECT_KEY}&branch=${ENCODED_BRANCH}"
59+ echo "url=${SONAR_URL}" >> $GITHUB_OUTPUT
60+ echo "### :bar_chart: SonarCloud Analysis Report" >> $GITHUB_STEP_SUMMARY
61+ echo "" >> $GITHUB_STEP_SUMMARY
62+ echo "**Branch:** \`${BRANCH_NAME}\`" >> $GITHUB_STEP_SUMMARY
63+ echo "" >> $GITHUB_STEP_SUMMARY
64+ echo "[View detailed SonarCloud report →]($SONAR_URL)" >> $GITHUB_STEP_SUMMARY
0 commit comments