51 lines
1.7 KiB
YAML
51 lines
1.7 KiB
YAML
name: SonarQube analyze
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
jobs:
|
|
build:
|
|
name: Build and analyze
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: 17
|
|
distribution: 'zulu' # Alternative distribution options are available.
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: '9.0.x'
|
|
- name: Cache SonarQube Cloud packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.sonar/cache
|
|
key: ${{ runner.os }}-sonar
|
|
restore-keys: ${{ runner.os }}-sonar
|
|
- name: Cache SonarQube Cloud scanner
|
|
id: cache-sonar-scanner
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.sonar/scanner
|
|
key: ${{ runner.os }}-sonar-scanner
|
|
restore-keys: ${{ runner.os }}-sonar-scanner
|
|
- name: Install SonarQube Cloud scanner
|
|
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
|
|
run: |
|
|
mkdir -p ~/.sonar/scanner
|
|
dotnet tool update dotnet-sonarscanner --tool-path ~/.sonar/scanner
|
|
- name: Restore dependencies
|
|
run: dotnet restore
|
|
- name: Build and analyze
|
|
env:
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
run: |
|
|
~/.sonar/scanner/dotnet-sonarscanner begin /k:"mrleo1nid_chatbot" /o:"mrleo1nid" /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|
|
dotnet build
|
|
~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" |