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
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: Build and Analyze with SonarCloud | |
on: | |
push: | |
branches: [ "develop", "devon4net_github_actions" ] | |
pull_request: | |
branches: [ "develop", "devon4net_github_actions" ] | |
jobs: | |
build: | |
name: Build and analyze | |
runs-on: ubuntu-latest # Change to Ubuntu | |
steps: | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 # Update to the latest version | |
with: | |
java-version: 17 | |
distribution: 'adopt' # Ubuntu uses AdoptOpenJDK | |
- uses: actions/checkout@v2 # Update to the latest version | |
with: | |
fetch-depth: 0 | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v2 # Update to the latest version | |
with: | |
path: ~/.sonar/cache # Change the path to the Linux format | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache SonarCloud scanner | |
id: cache-sonar-scanner | |
uses: actions/cache@v2 # Update to the latest version | |
with: | |
path: ./.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' | |
run: | | |
mkdir -p .sonar/scanner | |
dotnet tool update dotnet-sonarscanner --tool-path .sonar/scanner | |
- name: Build and analyze | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
./.sonar/scanner/dotnet-sonarscanner begin /k:"JosepFe_devon4net" /o:"josepfe" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" | |
cd source | |
dotnet restore | |
dotnet build | |
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" |