diff --git a/actions/sonar/action.yml b/actions/sonar/action.yml new file mode 100644 index 0000000..d553df6 --- /dev/null +++ b/actions/sonar/action.yml @@ -0,0 +1,49 @@ +name: "SonarQube Scan" +description: "Run SonarQube scan with Quality Gate enforcement" + +inputs: + sonar_host_url: + required: true + + sonar_token: + required: true + + wait_for_quality_gate: + required: false + default: "true" + +runs: + using: "composite" + steps: + - name: Set Project Key (from repo name) + shell: bash + run: | + echo "PROJECT_KEY=${{ gitea.event.repository.name }}" >> $GITHUB_ENV + + - name: Debug Info + shell: bash + run: | + echo "Project Key: $PROJECT_KEY" + echo "Wait for Quality Gate: ${{ inputs.wait_for_quality_gate }}" + + - name: Run Sonar Scanner + shell: bash + run: | + if [ "${{ inputs.wait_for_quality_gate }}" = "true" ]; then + sonar-scanner \ + -Dsonar.projectKey=$PROJECT_KEY \ + -Dsonar.projectName=$PROJECT_KEY \ + -Dsonar.sources=. \ + -Dsonar.host.url=${{ inputs.sonar_host_url }} \ + -Dsonar.token=${{ inputs.sonar_token }} \ + -Dsonar.exclusions=node_modules/**,dist/**,coverage/** \ + -Dsonar.qualitygate.wait=true + else + sonar-scanner \ + -Dsonar.projectKey=$PROJECT_KEY \ + -Dsonar.projectName=$PROJECT_KEY \ + -Dsonar.sources=. \ + -Dsonar.host.url=${{ inputs.sonar_host_url }} \ + -Dsonar.token=${{ inputs.sonar_token }} \ + -Dsonar.exclusions=node_modules/**,dist/**,coverage/** + fi \ No newline at end of file