@@ -7,24 +7,22 @@ name: SonarSource, SonarCloud, SonarQube
77on :
88 workflow_call :
99 inputs :
10- cert :
11- description : If SonarQube uses self-signed certificate, pass a root certificate (in PEM format)
10+ SONAR_HOST_URL :
11+ description : Specify the Sonar Host URL.
1212 type : string
13- default : ' '
14- host :
15- description : Specify SonarQube Host URL
16- type : string
17- default : ' '
18- gate :
19- description : Use SonarQube Quality Gate in Status Checks?
13+ default : ' https://sonarcloud.io'
14+ SONAR_QUALITY_GATE_CHECK :
15+ description : Use Sonar Quality Gate in Status Checks?
2016 type : boolean
2117 default : false
22- working-directory :
23- description : Directory in which to run Sonar Scanner
18+ projectBaseDir :
19+ description : Directory in which to run Sonar Scanner.
2420 type : string
25- default : ./
21+ default : ${{ $GITHUB_WORKSPACE }}
2622 secrets :
27- token :
23+ # If SonarQube uses self-signed certificate, pass a root certificate (in PEM format).
24+ SONAR_ROOT_CERT : ' '
25+ SONAR_TOKEN :
2826 required : true
2927
3028permissions :
@@ -43,40 +41,40 @@ jobs:
4341 fetch-depth : 0
4442
4543 - name : SonarCloud Scan
46- if : ${{ inputs.host == '' }}
44+ if : ${{ inputs.SONAR_HOST_URL == '' }}
4745 uses : SonarSource/sonarcloud-github-action@master
4846 with :
49- projectBaseDir : ${{ inputs.working-directory }}
47+ projectBaseDir : ${{ inputs.projectBaseDir }}
5048 env :
5149 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5250 # SonarCloud access token should be generated from https://sonarcloud.io/account/security/
53- SONAR_TOKEN : ${{ secrets.token }}
51+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
5452
5553 - name : SonarQube Scan
56- if : ${{ inputs.host != '' }}
54+ if : ${{ inputs.SONAR_HOST_URL != '' }}
5755 uses : sonarsource/sonarqube-scan-action@master
5856 with :
59- projectBaseDir : ${{ inputs.working-directory }}
57+ projectBaseDir : ${{ inputs.projectBaseDir }}
6058 env :
6159 # SonarQube access token should be generated from https://sonarcloud.io/account/security/
62- SONAR_TOKEN : ${{ secrets.token }}
63- SONAR_HOST_URL : ${{ inputs.host }}
64- # SONAR_ROOT_CERT: ${{ inputs.cert }}
60+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
61+ SONAR_HOST_URL : ${{ inputs.SONAR_HOST_URL }}
62+ # SONAR_ROOT_CERT: ${{ secrets.SONAR_ROOT_CERT }}
6563
6664 # Check the Quality Gate status.
6765 - name : SonarQube Quality Gate check
6866 id : sonarqube-quality-gate-check
69- if : ${{ inputs.host != '' && inputs.gate == true }}
67+ if : ${{ inputs.SONAR_HOST_URL != '' && inputs.SONAR_QUALITY_GATE_CHECK == true }}
7068 uses : sonarsource/sonarqube-quality-gate-action@master
7169 # Force to fail step after specific time.
7270 timeout-minutes : 5
7371 env :
74- SONAR_TOKEN : ${{ secrets.token }}
75- SONAR_HOST_URL : ${{ inputs.host }}
76- # SONAR_ROOT_CERT: ${{ inputs.cert }}
72+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
73+ SONAR_HOST_URL : ${{ inputs.SONAR_HOST_URL }}
74+ # SONAR_ROOT_CERT: ${{ secrets.SONAR_ROOT_CERT }}
7775
7876 # Optionally you can use the output from the Quality Gate in another step.
7977 # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`.
8078 - name : SonarQube Quality Gate Status
81- if : ${{ inputs.host != '' && inputs.gate == true }}
79+ if : ${{ inputs.SONAR_HOST_URL != '' && inputs.SONAR_QUALITY_GATE_CHECK == true }}
8280 run : echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}"
0 commit comments