Skip to content

Instantly share code, notes, and snippets.

@gadmel
Created February 28, 2023 22:06
Show Gist options
  • Save gadmel/634cf8eafb6f7b6b2e87b64adada36fd to your computer and use it in GitHub Desktop.
Save gadmel/634cf8eafb6f7b6b2e87b64adada36fd to your computer and use it in GitHub Desktop.
.github/workflows/sonar-backend.yml
name: Build Backend according to SonarCloud
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 19
uses: actions/setup-java@v3
with:
java-version: 19
distribution: 'zulu' # Alternative distribution options are available.
- 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: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey={{ secrets.SONAR_PROJECT_KEY }} --file backend/pom.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment