Skip to content

sonar

sonar #22

Workflow file for this run

name: sonar
on:
workflow_run:
workflows: [tests]
types: [completed]
jobs:
get-info:
runs-on: ubuntu-latest
outputs:
sourceHeadRepo: ${{ steps.workflow-run-info.outputs.sourceHeadRepo }}
sourceHeadBranch: ${{ steps.workflow-run-info.outputs.sourceHeadBranch }}
sourceHeadSha: ${{ steps.workflow-run-info.outputs.sourceHeadSha }}
mergeCommitSha: ${{ steps.workflow-run-info.outputs.mergeCommitSha }}
targetCommitSha: ${{ steps.workflow-run-info.outputs.targetCommitSha }}
pullRequestNumber: ${{ steps.workflow-run-info.outputs.pullRequestNumber }}
pullRequestLabels: ${{ steps.workflow-run-info.outputs.pullRequestLabels }}
targetBranch: ${{ steps.source-run-info.outputs.targetBranch }}
sourceEvent: ${{ steps.workflow-run-info.outputs.sourceEvent }}
steps:
- name: Get information about the source workflow
uses: potiuk/get-workflow-origin@v1
id: workflow-run-info
with:
token: ${{ secrets.GITHUB_TOKEN }}
sourceRunId: ${{ github.event.workflow_run.id }}
sonar-cloud:
needs: get-info
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- run: >
echo
${{ needs.get-info.outputs.sourceHeadRepo }}
${{ needs.get-info.outputs.sourceHeadBranch }}
${{ needs.get-info.outputs.sourceHeadSha }}
${{ needs.get-info.outputs.mergeCommitSha }}
${{ needs.get-info.outputs.targetCommitSha }}
${{ needs.get-info.outputs.pullRequestNumber }}
${{ needs.get-info.outputs.pullRequestLabels }}
${{ needs.get-info.outputs.targetBranch }}
${{ needs.get-info.outputs.sourceEvent }}
- uses: actions/checkout@v3
with:
repository: ${{ github.event.workflow_run.head_repository.full_name }}
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 0
- name: Download code coverage
uses: dawidd6/action-download-artifact@v2
with:
workflow: tests.yml
commit: ${{ github.event.workflow_run.head_sha }}
name: report-output
path: build/reports
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: ${{ vars.JAVA_VENDOR }}
java-version: ${{ vars.JAVA_VERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
- name: SonarCloud analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >
./gradlew sonar --info
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }}
-Dsonar.pullrequest.key=${{ github.event.workflow_run.pull_requests[0].number }}
-Dsonar.pullrequest.branch=${{ github.event.workflow_run.pull_requests[0].head.ref }}
-Dsonar.pullrequest.base=${{ github.event.workflow_run.pull_requests[0].base.ref }}