forked from Skillfyme06-Nov-Org/SonarQubeCoverageJava
-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (52 loc) · 2.21 KB
/
Copy pathmain.yml
File metadata and controls
52 lines (52 loc) · 2.21 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
name: build JAVA with artifact application
on:
workflow_dispatch: # multiple triggers when this workflow can run
inputs: # user to select the jobname
job_name: # can be any name like a variable name
description: "Select the Job to run" # desciption visible to user
required: true # user should mandatory select one job for the workflow to start
type: choice # job_name stores multiple values for user to select
options: # give correct job names
- job1_build
- job2_codeCoverage
jobs:
job1_build:
if: ${{ github.event.inputs.job_name == 'job1_build' }}
# run above job when input selected is job1_build
runs-on: ubuntu-latest
steps:
- name: Clone the repo
uses: actions/checkout@v6
- name: Install java on runner
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
- name: build java code
run: mvn clean package
job2_codeCoverage:
if: ${{ github.event.inputs.job_name == 'job2_codeCoverage' }}
#needs: job1_build # creating dependency between 2 jobs.
# first build job will be completed and then code coverage will start
runs-on: ubuntu-latest
steps:
- name: Clone the repo
uses: actions/checkout@v6
- name: Install java on runner
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
- name: build java code
run: mvn clean package
- name: Code Coverage using sonarcloud
run: mvn -B verify sonar:sonar -Dsonar.projectKey=sonar-qube-org-demo-nov_sonar-demo-org-nov-2025-project -Dsonar.organization=sonar-qube-org-demo-nov -Dsonar.host.url=https://sonarcloud.io -Dsonar.token=$SONAR_TOKEN
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GITHUB_TOKEN: Automatically generated token for GitHub API authentication (with limited scope).
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN}}
- name: upload artifact to github repo
uses: actions/upload-artifact@v4 # Use the latest version
with:
name: myjava-build-artifact
path: /home/runner/work/SonarQubeCoverageJava/SonarQubeCoverageJava/target/wicket-pwnedpasswords-validator-2.0.1-SNAPSHOT.jar