@@ -11,12 +11,25 @@ name: any-sonar-template
1111 required : false
1212 default : " ."
1313 type : string
14+ sonar_host_url :
15+ description : " Sonar host url"
16+ required : false
17+ default : " https://sonarcloud.io"
18+ type : string
19+ sonar_organization :
20+ description : " Sonar organization (login)"
21+ required : true
22+ type : string
23+ sonar_project_key :
24+ description : " Sonar project key"
25+ required : true
26+ type : string
1427 secrets :
15- GH_TOKEN :
16- description : ' GitHub Token'
28+ github_token :
29+ description : " GitHub Token"
1730 required : true
18- SN_TOKEN :
19- description : ' Sonar Token'
31+ sonar_token :
32+ description : " Sonar Token"
2033 required : true
2134defaults :
2235 run :
@@ -49,11 +62,53 @@ jobs:
4962 path : ~/.sonar/cache
5063 key : ${{ runner.os }}-sonar
5164 restore-keys : ${{ runner.os }}-sonar
65+ - name : Create pom.xml if not exists
66+ working-directory : ${{ inputs.working-directory }}
67+ run : |
68+ cat <<EOF > pom.xml
69+ <?xml version="1.0" encoding="UTF-8"?>
70+ <project xmlns="http://maven.apache.org/POM/4.0.0"
71+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
72+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
73+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
74+ <modelVersion>4.0.0</modelVersion>
75+ <groupId>com.github.fabriciofx.github.workflows</groupId>
76+ <artifactId>sonar-template</artifactId>
77+ <version>0.0.1</version>
78+ <profiles>
79+ <profile>
80+ <id>sonar</id>
81+ <properties>
82+ <sonar.host.url>${{ inputs.sonar_host_url }}</sonar.host.url>
83+ <sonar.organization>${{ inputs.sonar_organization }}</sonar.organization>
84+ <sonar.projectKey>${{ inputs.sonar_project_key }}</sonar.projectKey>
85+ </properties>
86+ <build>
87+ <plugins>
88+ <plugin>
89+ <groupId>org.sonarsource.scanner.maven</groupId>
90+ <artifactId>sonar-maven-plugin</artifactId>
91+ <version>5.2.0.4988</version>
92+ <executions>
93+ <execution>
94+ <phase>package</phase>
95+ <goals>
96+ <goal>sonar</goal>
97+ </goals>
98+ </execution>
99+ </executions>
100+ </plugin>
101+ </plugins>
102+ </build>
103+ </profile>
104+ </profiles>
105+ </project>
106+ EOF
52107 - name : Run Sonar
53108 working-directory : ${{ inputs.working-directory }}
54109 env :
55- GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
56- SONAR_TOKEN : ${{ secrets.SN_TOKEN }}
110+ GITHUB_TOKEN : ${{ secrets.github_token }}
111+ SONAR_TOKEN : ${{ secrets.sonar_token }}
57112 run : |
58113 [[ -x "mvnw" ]] && mvn="./mvnw" || mvn="mvn"
59114 args=(--errors --batch-mode package)
0 commit comments