* Updating docker action * adding version to message * adding way to get PR title and body * Adding input pass to workflows Workflow dispatches may not get push header info. Switching logic to pass needed title and body info through just in case.
152 lines
4.3 KiB
YAML
152 lines
4.3 KiB
YAML
name: .NET Build Test and Sonar Scan
|
|
|
|
on:
|
|
push:
|
|
branches: '**'
|
|
pull_request:
|
|
branches: [ main, develop ]
|
|
types: [opened, synchronize, reopened]
|
|
|
|
jobs:
|
|
build:
|
|
name: Build .Net
|
|
runs-on: windows-latest
|
|
steps:
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup .NET Core
|
|
uses: actions/setup-dotnet@v1
|
|
with:
|
|
dotnet-version: 5.0.100
|
|
|
|
- name: Install dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Set up JDK 11
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: 1.11
|
|
|
|
- uses: actions/upload-artifact@v2
|
|
with:
|
|
name: csproj
|
|
path: Kavita.Common/Kavita.Common.csproj
|
|
|
|
test:
|
|
name: Install Sonar & Test
|
|
needs: build
|
|
runs-on: windows-latest
|
|
steps:
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup .NET Core
|
|
uses: actions/setup-dotnet@v1
|
|
with:
|
|
dotnet-version: 5.0.100
|
|
|
|
- name: Install dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Set up JDK 11
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: 1.11
|
|
|
|
- name: Cache SonarCloud packages
|
|
uses: actions/cache@v1
|
|
with:
|
|
path: ~\sonar\cache
|
|
key: ${{ runner.os }}-sonar
|
|
restore-keys: ${{ runner.os }}-sonar
|
|
|
|
- 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
|
|
run: |
|
|
New-Item -Path .\.sonar\scanner -ItemType Directory
|
|
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
|
|
|
|
- name: Sonar Scan
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
shell: powershell
|
|
run: |
|
|
.\.sonar\scanner\dotnet-sonarscanner begin /k:"Kareadita_Kavita" /o:"kareadita" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
|
|
dotnet build --configuration Release
|
|
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
|
|
|
|
- name: Test
|
|
run: dotnet test --no-restore --verbosity normal
|
|
|
|
version:
|
|
name: Bump version on Develop push
|
|
needs: [ build, test ]
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup .NET Core
|
|
uses: actions/setup-dotnet@v1
|
|
with:
|
|
dotnet-version: 5.0.100
|
|
|
|
- name: Install dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
run: dotnet build --configuration Release --no-restore
|
|
|
|
- name: Bump versions
|
|
uses: SiqiLu/dotnet-bump-version@master
|
|
with:
|
|
version_files: Kavita.Common/Kavita.Common.csproj
|
|
github_token: ${{ secrets.REPO_GHA_PAT }}
|
|
|
|
develop:
|
|
name: Trigger Nightly Docker if Develop push
|
|
needs: [ build, test, version ]
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
|
|
steps:
|
|
|
|
- name: Find Current Pull Request
|
|
uses: jwalton/gh-find-current-pr@v1.0.2
|
|
id: findPr
|
|
|
|
- name: If Push to Develop, Trigger Docker Stable
|
|
uses: benc-uk/workflow-dispatch@v1
|
|
with:
|
|
workflow: Build Nightly Docker
|
|
token: ${{ secrets.REPO_GHA_PAT }}
|
|
inputs: '{ "title": "${{ steps.findPr.outputs.title }}", "body": "${{ steps.findPr.outputs.body }}" }'
|
|
|
|
stable:
|
|
name: Trigger Stable Docker if Main push
|
|
needs: [ build, test ]
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
|
steps:
|
|
|
|
- name: If Push to Main, Trigger Docker Stable
|
|
uses: benc-uk/workflow-dispatch@v1
|
|
with:
|
|
workflow: Build Stable Docker
|
|
token: ${{ secrets.REPO_GHA_PAT }}
|