Actions CI Build #852
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Actions CI Build | |
on: | |
push: | |
branches: [ develop, master ] | |
pull_request: | |
branches: [ develop, master ] | |
schedule: | |
- cron: '30 0 * * 0' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# Disabling shallow clone is recommended by SonarQube for improving relevancy of reporting | |
fetch-depth: 0 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '21' # The JDK version to make available on the path. | |
java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk | |
architecture: x64 # (x64 or x86) - defaults to x64 | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache Maven packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Start MongoDB | |
uses: supercharge/mongodb-github-action@1.10.0 | |
with: | |
mongodb-version: 4.4 | |
- if: ${{ github.actor != 'dependabot[bot]' }} | |
name: Build with Maven and run Sonar reports | |
run: > | |
mvn -B clean package org.sonarsource.scanner.maven:sonar-maven-plugin:sonar --file pom.xml | |
-Dspring.profiles.active=ci | |
-Dsonar.sources=src/main | |
-Dsonar.java.binaries=target/classes | |
-Dsonar.projectName="Books Microservice" | |
-Dsonar.sourceEncoding=UTF-8 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
- if: ${{ github.actor == 'dependabot[bot]' }} | |
name: Build with Maven without Sonar | |
run: > | |
mvn -B clean package --file pom.xml | |
-Dspring.profiles.active=ci | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |