|
| 1 | +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time |
| 2 | +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven |
| 3 | + |
| 4 | +# This workflow uses actions that GitHub does not certify. |
| 5 | +# They are provided by a third-party and are governed by |
| 6 | +# separate terms of service, privacy policy, and support |
| 7 | +# documentation. |
| 8 | + |
| 9 | +name: Java CI with Maven and SonarCloud |
| 10 | + |
| 11 | +on: |
| 12 | + push: |
| 13 | + branches: ["main", "2025.4"] |
| 14 | + pull_request: |
| 15 | + types: [opened, synchronize, reopened] |
| 16 | +jobs: |
| 17 | + validate: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v5 |
| 21 | + with: |
| 22 | + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
| 23 | + |
| 24 | + - name: Use Node.js 18.10.0 |
| 25 | + uses: actions/setup-node@v5 |
| 26 | + with: |
| 27 | + node-version: 18.10.0 |
| 28 | + - name: Install Angular Cli |
| 29 | + run: npm i -g @angular/cli |
| 30 | + |
| 31 | + - name: Set up JDK 21 |
| 32 | + uses: actions/setup-java@v5 |
| 33 | + with: |
| 34 | + java-version: "21" |
| 35 | + distribution: "temurin" |
| 36 | + cache: maven |
| 37 | + - name: Cache SonarCloud packages |
| 38 | + uses: actions/cache@v4 |
| 39 | + with: |
| 40 | + path: ~/.sonar/cache |
| 41 | + key: ${{ runner.os }}-sonar |
| 42 | + restore-keys: ${{ runner.os }}-sonar |
| 43 | + - name: Cache Maven packages |
| 44 | + uses: actions/cache@v4 |
| 45 | + with: |
| 46 | + path: ~/.m2 |
| 47 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 48 | + restore-keys: ${{ runner.os }}-m2 |
| 49 | + |
| 50 | + - name: Build and analyze |
| 51 | + env: |
| 52 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 54 | + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dgpg.skip=true -Dsonar.projectKey=viglet_dumont |
0 commit comments