Skip to content

Merge pull request #144 from litetex/renovate/serilog-4.x #187

Merge pull request #144 from litetex/renovate/serilog-4.x

Merge pull request #144 from litetex/renovate/serilog-4.x #187

Workflow file for this run

name: Sonar CI
on:
workflow_dispatch:
push:
branches: [ master, dev ]
paths-ignore:
- '**.md'
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- '**.md'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
sonar:
name: SonarCloud Scan
runs-on: ubuntu-latest
# Automated Dependency PRs have no access to secrets (SONAR_TOKEN) -> Ignore them
if: ${{ github.event_name != 'pull_request' || !(startsWith(github.head_ref, 'renovate/') || startsWith(github.head_ref, 'dependabot/')) }}
steps:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21.x
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v4
with:
path: ./src/.sonar/scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
working-directory: src
run: |
mkdir -p .sonar/scanner
dotnet tool update dotnet-sonarscanner --tool-path .sonar/scanner
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
working-directory: src
run: |
.sonar/scanner/dotnet-sonarscanner begin /k:"litetex_CoreFrameworkBase" /o:"litetex" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build --configuration Release
.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"