Skip to content

Build and release C# .NET8 test function #21

Build and release C# .NET8 test function

Build and release C# .NET8 test function #21

# 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 release C# .NET8 test function
on:
push:
branches: [ "master" ]
paths:
- /src/Azure/Csharp.net8/**
workflow_dispatch:
jobs:
buildTestWindows:
name: Build Test Function
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Publish windows
run: dotnet publish ./src/Azure/Csharp.net8/CloudRepublic.BenchMark.SampleFunction.Net8/CloudRepublic.BenchMark.SampleFunction.Net8.csproj --runtime "win-x64" --output ./outputs/test/windows --configuration "RELEASE"
- name: Debugging info
run: ls ./outputs/test
- name: Zip outputs windows
shell: pwsh
working-directory: ${{ github.workspace }}/outputs/test/windows
run: Compress-Archive .\* ${{ github.workspace }}/windows.zip
- name: Upload a Build Artifact windows
uses: actions/upload-artifact@v3.1.1
with:
name: windows
path: ./windows.zip
buildTestLinux:
name: Build Test Function
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Install zip
uses: montudor/action-zip@v1
- name: Restore dependencies
run: dotnet restore
- name: Publish linux
run: dotnet publish ./src/Azure/Csharp.net8/CloudRepublic.BenchMark.SampleFunction.Net8/CloudRepublic.BenchMark.SampleFunction.Net8.csproj --runtime "linux-x64" --output ./outputs/test/linux --configuration "RELEASE"
- name: Debugging info
run: ls ./outputs/test
- name: Zip outputs linux
working-directory: ${{ github.workspace }}/outputs/test/linux
run: zip -qq -r ${{ github.workspace }}/linux.zip .
- name: Upload a Build Artifact linux
uses: actions/upload-artifact@v3.1.1
with:
name: linux
path: ./linux.zip
deploy:
name: Deploy application
runs-on: ubuntu-latest
needs: ["buildTestWindows", "buildTestLinux"]
steps:
# Checkout code
- uses: actions/checkout@v3
# Log into Azure
- name: login to azure cli
run: az login --service-principal -u ${{ secrets.AZURE_APPID }} -p ${{ secrets.AZURE_APPSECRET }} --tenant ${{ secrets.AZURE_TENANT }}
- name: deploy bicep
run: az stack group create --subscription "${{ secrets.AZURE_SUBSCRIPTION }}" --resource-group "${{ secrets.AZURE_RG }}" --template-file ./src/Azure/Csharp.net8/CloudRepublic.BenchMark.SampleFunction.Net8/deployment.bicep --parameters prefix=${{ secrets.DEPLOYMENT_PREFIX }} --name cs-net8 --deny-settings-mode None --delete-resources true --deny-settings-excluded-principals ${{ secrets.AZURE_OBJECTID }}
- name: Download Test Artifact Linux
uses: actions/download-artifact@v3.0.1
with:
name: linux
path: ./outputs/test/linux
- name: Download Test Artifact Windows
uses: actions/download-artifact@v3.0.1
with:
name: windows
path: ./outputs/test/windows
- name: Deploy linux test
run: az functionapp deployment source config-zip --subscription "${{ secrets.AZURE_SUBSCRIPTION }}" --resource-group "${{ secrets.AZURE_RG }}" --src "./outputs/test/linux/linux.zip" --name "${{ secrets.DEPLOYMENT_PREFIX }}cseightlin"
- name: Deploy windows test
run: az functionapp deployment source config-zip --subscription "${{ secrets.AZURE_SUBSCRIPTION }}" --resource-group "${{ secrets.AZURE_RG }}" --src "./outputs/test/windows/windows.zip" --name "${{ secrets.DEPLOYMENT_PREFIX }}cseightwin"