Skip to content

Commit

Permalink
Update build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
jslachta committed Oct 17, 2022
1 parent 16ae111 commit 08d3f5b
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,61 @@
name: Build

on:
# Trigger analysis when pushing in master or pull requests, and when creating
# a pull request.
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
types:
- opened
- synchronize
- reopened

jobs:
build:
name: Build
sonarcloud:
name: SonarCloud
runs-on: windows-latest
steps:
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.11
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages
# Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0

# Speed-up analysis by caching the scanner workspace
- name: Cache SonarCloud workspace
uses: actions/cache@v1
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
path: ~\.sonar\cache
key: ${{ runner.os }}-sonar-cache
restore-keys: ${{ runner.os }}-sonar-cache

# Speed-up analysis by caching the scanner installation
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v1
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'
shell: powershell
# The --version argument is optional. If it is omitted the latest version will be installed.
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
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 }}
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner --version 4.8.0
- name: Build
shell: powershell
env:
# Needed to get some information about the pull request, if any
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# The secret referenced in the command-line by SONAR_TOKEN should be generated
# from https://sonarcloud.io/account/security/
# The organization and project arguments (see /o and /k) are displayed
# on the project dashboard in SonarCloud.
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"jslachta_LocaleNames" /o:"jslachta" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
.\.sonar\scanner\dotnet-sonarscanner begin /k:"SonarSource_sonarcloud-github-action-samples" /o:"sonarsource" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build src/LocaleNames.sln
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"

0 comments on commit 08d3f5b

Please sign in to comment.