Skip to content

vaas-dotnet-ci

vaas-dotnet-ci #266

Workflow file for this run

name: vaas-dotnet-ci
on:
push:
branches:
- main
paths:
- "dotnet/**"
- ".github/workflows/ci-dotnet.yaml"
tags:
- "cs*"
pull_request:
branches:
- main
paths:
- "dotnet/**"
- ".github/workflows/ci-dotnet.yaml"
workflow_dispatch:
jobs:
build-dotnet:
name: Build & Test C# SDK
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ["6.0.x"]
steps:
- uses: actions/checkout@v3
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Install dependencies
run: dotnet res
working-directory: dotnet/Vaas
- name: extract version
if: startsWith(github.ref, 'refs/tags/cs')
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/cs}" >> $GITHUB_ENV
echo $RELEASE_VERSION
- name: set version
if: startsWith(github.ref, 'refs/tags/cs')
run: |
sed -i "s/<Version>0\.0\.0/<Version>$RELEASE_VERSION/g" ./dotnet/Vaas/src/Vaas/Vaas.csproj
- name: Build
run: dotnet build --configuration Release --no-restore
working-directory: dotnet/Vaas
- name: Test
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/cs')
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
VAAS_URL: "wss://gateway.production.vaas.gdatasecurity.de"
TOKEN_URL: "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"
run: dotnet test --no-restore --verbosity normal
working-directory: dotnet/Vaas
- name: Test staging
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/cs')
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.STAGING_CLIENT_SECRET }}
VAAS_URL: "wss://gateway.staging.vaas.gdatasecurity.de"
TOKEN_URL: "https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token"
run: dotnet test --no-restore --verbosity normal
working-directory: dotnet/Vaas
- name: Run example FileScan
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
SCAN_PATH: "Program.cs"
run: dotnet run FileScan
working-directory: dotnet/examples/VaasExample
- name: Run example UrlScan
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
run: dotnet run UrlScan
working-directory: dotnet/examples/VaasExample
- name: Pack
if: startsWith(github.ref, 'refs/tags/cs')
run: dotnet pack -c Release src/Vaas
working-directory: dotnet/Vaas
- name: Push to nuget
if: startsWith(github.ref, 'refs/tags/cs')
env:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
NUGET_FEED: https://api.nuget.org/v3/index.json
run: dotnet nuget push src/Vaas/bin/Release/*.nupkg --skip-duplicate --source $NUGET_FEED --api-key $NUGET_KEY
working-directory: dotnet/Vaas
if_failure:
name: Only if failure
runs-on: ubuntu-latest
steps:
- name: Microsoft Teams Notification
uses: skitionek/notify-microsoft-teams@master
if: failure()
with:
webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}