SonarCube Static Scans (PR) #113
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SonarCube Static Scans (PR) | |
on: | |
workflow_run: | |
workflows: | |
- Provider Unit Tests | |
types: | |
- completed | |
permissions: read-all | |
jobs: | |
sonarcloud: | |
name: SonarQube Static Scans (PR) | |
runs-on: ubuntu-latest | |
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' | |
steps: | |
- name: Checkout Provider | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Fetch Code Coverage Report | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage-report | |
path: . | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
run-id: ${{ github.event.workflow_run.id }} | |
- name: Fetch PR Number | |
uses: actions/download-artifact@v4 | |
with: | |
name: pr_number | |
path: . | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
run-id: ${{ github.event.workflow_run.id }} | |
- name: Extract PR Number | |
run: | | |
cat pr_number.txt | |
echo $(head -n1 pr_number.txt | awk '{print $2}') | |
echo "PR_NUMBER=$(head -n1 pr_number.txt | awk '{print $2}')" >> $GITHUB_ENV | |
- name: Get Additional PR Information | |
uses: octokit/[email protected] | |
id: pr_info | |
with: | |
route: GET /repos/{repo}/pulls/{number} | |
repo: ${{ github.event.repository.full_name }} | |
number: ${{ env.PR_NUMBER }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Additional PR Information | |
run: | | |
echo "PR_BASE=${{ fromJson(steps.pr_info.outputs.data).base.ref }}" >> $GITHUB_ENV | |
echo "PR_HEAD=${{ fromJson(steps.pr_info.outputs.data).head.ref }}" >> $GITHUB_ENV | |
- name: Checkout Code for PR | |
run: | | |
gh pr checkout ${{ env.PR_NUMBER }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: SonarCube Scan | |
uses: SonarSource/[email protected] | |
env: | |
SONAR_TOKEN: ${{ secrets[format('{0}', vars.SONAR_TOKEN_SECRET_NAME)] }} | |
with: | |
args: > | |
-Dsonar.go.coverage.reportPaths=unit-testing.cov | |
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} | |
-Dsonar.pullrequest.key=${{ env.PR_NUMBER }} | |
-Dsonar.pullrequest.branch=${{ env.PR_HEAD }} | |
-Dsonar.pullrequest.base=${{ env.PR_BASE }} |