-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (47 loc) · 1.49 KB
/
sonar.yml
File metadata and controls
53 lines (47 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Manual SonarCloud Analysis
on:
workflow_dispatch:
inputs:
pr_id:
description: 'Pull Request ID to analyze'
required: true
type: string
jobs:
sonar-analysis:
name: SonarCloud Analysis for PR
runs-on: ubuntu-latest
steps:
- name: Get PR details
id: pr
uses: actions/github-script@v7
with:
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ inputs.pr_id }}
});
core.setOutput('head_ref', pr.data.head.ref);
core.setOutput('base_ref', pr.data.base.ref);
core.setOutput('head_sha', pr.data.head.sha);
- uses: actions/checkout@v6
with:
ref: ${{ steps.pr.outputs.head_sha }}
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: 17
distribution: 'temurin'
cache: maven
- name: Build/Test & SonarCloud Scan
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
PR_ID: ${{ inputs.pr_id }}
if: env.SONAR_TOKEN != ''
run: |
mvn -B clean verify -Pcoverage,sonar \
-Dsonar.token=$SONAR_TOKEN \
-Dsonar.pullrequest.key=$PR_ID \
-Dsonar.pullrequest.branch=${{ steps.pr.outputs.head_ref }} \
-Dsonar.pullrequest.base=${{ steps.pr.outputs.base_ref }}