Sonarcloud scan #2737
This file contains 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: Sonarcloud scan | |
on: | |
workflow_run: | |
workflows: [Java checkstyle] | |
types: [completed] | |
jobs: | |
sonarcloud-scan: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.workflow_run.head_repository.full_name }} | |
ref: ${{ github.event.workflow_run.head_branch }} | |
fetch-depth: 0 | |
- name: Download Java built artifact | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.payload.workflow_run.id, | |
}); | |
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "java-built-files" | |
})[0]; | |
let download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
let fs = require('fs'); | |
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/java-built-files.zip`, Buffer.from(download.data)); | |
- name: Unzip java built artifact | |
run: | | |
unzip java-built-files.zip | |
- name: Unpacking the build results | |
run: tar xf java-build.tar.gz | |
- name: Read the PR data file | |
run: cat pr_data >>"$GITHUB_ENV" | |
- name: SonarCloud Scan | |
uses: sonarsource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONARQUBE_AUTH_UYUNI }} | |
with: | |
args: > | |
-Dsonar.junit.reportPaths="" | |
-Dsonar.coverage.jacoco.xmlReportPaths="" | |
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} | |
-Dsonar.pullrequest.key=${{ env.PR_NUMBER }} | |
-Dsonar.pullrequest.branch=${{ github.event.workflow_run.head_branch }} | |
-Dsonar.pullrequest.base=${{ env.PR_BASE }} |