@@ -7,15 +7,20 @@ name: Java CI with Maven
77
88env :
99 JAVA : 17
10- PRIVILEGED_RUN : ${{ (github.event_name == 'push' && github.ref == 'refs/heads/development')
11- || github.event.pull_request.head.repo.full_name == github.repository }}
12- CODEQL_LANGUAGES : ' java' # FIXME(@JonasCir) add 'javascript'
10+ PRIVILEGED_RUN : ${{ (github.event_name == 'push' && github.ref == 'refs/heads/development') || github.event.pull_request.head.repo.full_name == github.repository }}
11+ CODEQL_LANGUAGES : ' java'
1312on :
1413 push :
1514 branches : [ development, master, hotfix* ]
1615 pull_request :
1716 branches : [ development, hotfix* ]
1817 workflow_dispatch : # run it manually from the GH Actions web console
18+ inputs :
19+ skip_tests :
20+ description : ' Skip Maven tests during build'
21+ required : false
22+ default : false
23+ type : boolean
1924 schedule :
2025 - cron : ' 35 1 * * 0'
2126jobs :
@@ -31,24 +36,24 @@ jobs:
3136 # The token is only needed for privileged actions from within the repo, so no need
3237 # to make it available on 3rd party PRs
3338 if : ${{ fromJSON(env.PRIVILEGED_RUN) }}
34- uses : actions/checkout@v3
39+ uses : actions/checkout@v6
3540 with :
36- token : ${{ secrets.SORMAS_VITAGROUP_CI_TOKEN }}
41+ token : ${{ secrets.MAVEN_ACTIONS_TOKEN }}
3742
3843 - name : Checkout repository (without token)
3944 # Check if PR results from a fork: if yes, we cannot access the token.
4045 # The token is only needed for privileged actions from within the
4146 # repo, so no need to make it available on 3rd party PRs
4247 if : ${{ !fromJSON(env.PRIVILEGED_RUN) }}
43- uses : actions/checkout@v3
48+ uses : actions/checkout@v6
4449
4550 - name : Initialize CodeQL
46- uses : github/codeql-action/init@v2
51+ uses : github/codeql-action/init@v4
4752 with :
4853 languages : ${{ env.CODEQL_LANGUAGES }}
4954
5055 - name : Set up JDK ${{ env.JAVA }}
51- uses : actions/setup-java@v3
56+ uses : actions/setup-java@v5
5257 with :
5358 java-version : ${{ env.JAVA }}
5459 distribution : ' zulu'
@@ -57,47 +62,26 @@ jobs:
5762 # Check if PR results from the repository: if yes, it is safe to cache dependencies.
5863 # This is to keep us safe from cache poisoning through 3rd party PRs.
5964 if : ${{ fromJSON(env.PRIVILEGED_RUN) }}
60- uses : actions/cache@v3
65+ uses : actions/cache@v5
6166 with :
6267 path : ~/.m2
6368 key : ${{ runner.os }}-java-${{ env.JAVA }}-m2-${{ hashFiles('**/pom.xml') }}
6469 restore-keys : ${{ runner.os }}-java-${{ env.JAVA }}-m2
6570
66- - name : Cache SonarCloud packages
67- # Check if PR results from the repository: if yes, it is safe to cache dependencies.
68- # This is to keep us safe from cache poisoning through 3rd party PRs.
69- if : ${{ fromJSON(env.PRIVILEGED_RUN) }}
70- uses : actions/cache@v3
71- with :
72- path : ~/.sonar/cache
73- key : ${{ runner.os }}-sonar
74- restore-keys : ${{ runner.os }}-sonar
75- - name : Run mvn verify and sonar analysis
76- # FIXME(@JonasCir) see https://github.com/sormas-foundation/SORMAS-Project/issues/3730#issuecomment-745165678
77- env :
78- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
79- SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
71+ - name : Build with Maven
8072 working-directory : ./sormas-base
81- run : mvn -B -ntp verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=SORMAS-Project
82-
83- - name : Comment with SonarCloud analysis
84- uses : actions/github-script@v6
85- if : github.event_name == 'pull_request'
86- with :
87- github-token : ${{ secrets.SORMAS_VITAGROUP_CI_TOKEN }}
88- script : |
89- github.rest.issues.createComment({
90- issue_number: context.issue.number,
91- owner: context.repo.owner,
92- repo: context.repo.repo,
93- body: `SonarCloud analysis: https://sonarcloud.io/dashboard?id=SORMAS-Project&pullRequest=${{ github.event.pull_request.number }}`
94- })
73+ run : |
74+ MAVEN_OPTS="-B -ntp clean install"
75+ if [ "${{ inputs.skip_tests }}" = "true" ]; then
76+ MAVEN_OPTS="$MAVEN_OPTS -DskipTests"
77+ fi
78+ mvn $MAVEN_OPTS
9579
9680 - name : Perform CodeQL Analysis
97- uses : github/codeql-action/analyze@v2
81+ uses : github/codeql-action/analyze@v4
9882
9983 - name : Run Trivy vulnerability scanner in repo mode
100- uses : aquasecurity/trivy-action@0.11.2
84+ uses : aquasecurity/trivy-action@0.35.0
10185 with :
10286 scan-type : ' fs'
10387 ignore-unfixed : true
10690 scanners : ' vuln,secret,config'
10791
10892 - name : Upload Trivy scan results to GitHub Security tab
109- uses : github/codeql-action/upload-sarif@v2
93+ uses : github/codeql-action/upload-sarif@v4
11094 with :
11195 sarif_file : ' trivy-results.sarif'
11296 # needed as codeQL also performs an upload, and they clash otherwise
@@ -115,12 +99,11 @@ jobs:
11599 - name : Commit openAPI spec to development
116100 # Privileged action needing a secret token. Since this only runs on development in our own repo
117101 # the token will be available through a privileged checkout.
118- if : github.event_name == 'push' && github.ref == 'refs/heads/development'
119- && hashFiles('sormas-rest/target/swagger.yaml') != hashFiles('sormas-rest/swagger.yaml')
102+ if : github.event_name == 'push' && github.ref == 'refs/heads/development' && hashFiles('sormas-rest/target/swagger.yaml') != hashFiles('sormas-rest/swagger.yaml')
120103 # https://stackoverflow.com/questions/59604922/authorize-bash-to-access-github-protected-branch
121104 run : |
122- git config --global user.name "sormas-vitagroup "
123- git config --global user.email "support.sormas@helpdesk.symeda.de "
105+ git config --global user.name "sormas-robot "
106+ git config --global user.email "accounts@sormas.org "
124107
125108 mkdir /tmp/openapi
126109 cp sormas-rest/target/swagger.* /tmp/openapi
0 commit comments