Update maven-build.yml

This commit is contained in:
Shihan Zhang 2024-04-05 12:56:11 -04:00 committed by GitHub
parent 516722647a
commit 6e0ffc1860
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,21 +9,51 @@ on:
pull_request: pull_request:
branches: [ main ] branches: [ main ]
# jobs:
# build:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# java: [ '17' ]
# steps:
# - uses: actions/checkout@v4
# - name: Set up JDK ${{matrix.java}}
# uses: actions/setup-java@v4
# with:
# java-version: ${{matrix.java}}
# distribution: 'adopt'
# cache: maven
# - name: Build with Maven Wrapper
# run: ./mvnw -B package
jobs: jobs:
build: build:
name: Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: permissions: read-all
matrix:
java: [ '17' ]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v2
- name: Set up JDK ${{matrix.java}}
uses: actions/setup-java@v4
with: with:
java-version: ${{matrix.java}} fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
distribution: 'adopt' - name: Set up JDK 17
cache: maven uses: actions/setup-java@v1
- name: Build with Maven Wrapper with:
run: ./mvnw -B package java-version: 17
- name: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=petclinic -Dsonar.projectName='petclinic'