-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 additions
and
18 deletions.
There are no files selected for viewing
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
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 }}" |