Skip to content

sonar

sonar #391

Workflow file for this run

name: sonar
on:
workflow_run:
workflows: [tests]
types: [completed]
jobs:
get-info:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
outputs:
sourceHeadBranch: ${{ steps.workflow-run-info.outputs.sourceHeadBranch }}
sourceHeadSha: ${{ steps.workflow-run-info.outputs.sourceHeadSha }}
pullRequestNumber: ${{ steps.workflow-run-info.outputs.pullRequestNumber }}
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 }}
- uses: octokit/request-action@v2.x
id: get_latest_release
with:
route: GET /repos/{owner}/{repo}/actions/runs/{run_id}
owner: harrel56
repo: json-schema
run_id: ${{ github.event.workflow_run.id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: "echo latest release: '${{ steps.get_latest_release.outputs.data }}'"
- run: "echo latest release: '${{ fromJSON(steps.get_latest_release.outputs.data).head_branch }}'"
sonar-cloud:
if: github.event.workflow_run.conclusion == 'success'
needs: get-info
runs-on: ubuntu-latest
steps:
- 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 code coverage
uses: dawidd6/action-download-artifact@v3
with:
workflow: tests.yml
commit: ${{ github.event.workflow_run.head_sha }}
name: report-output
path: build
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: ${{ vars.JAVA_VENDOR }}
java-version: ${{ vars.JAVA_VERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v3
with:
gradle-version: wrapper
- name: SonarCloud analyze master
if: needs.get-info.outputs.pullRequestNumber == ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew sonar --no-daemon
- name: SonarCloud analyze PR
if: needs.get-info.outputs.pullRequestNumber != ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >
./gradlew sonar --no-daemon
-Dsonar.scm.revision=${{ needs.get-info.outputs.sourceHeadSha }}
-Dsonar.pullrequest.key=${{ needs.get-info.outputs.pullRequestNumber }}
-Dsonar.pullrequest.branch=${{ needs.get-info.outputs.sourceHeadBranch }}
-Dsonar.pullrequest.base=master