Build and release Csharp test function #5
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
# 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 Csharp test function | |
on: | |
push: | |
branches: [ "master" ] | |
paths: | |
- /src/Azure/Csharp/** | |
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: 6.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Publish | |
run: dotnet publish --runtime "win-x64" ./src/Azure/Csharp/CloudRepublic.BenchMark.SampleFunction/CloudRepublic.BenchMark.SampleFunction.csproj --output ./outputs/test --configuration "RELEASE" | |
- name: Debugging info | |
run: ls ./outputs/test | |
- name: Zip outputs | |
shell: pwsh | |
working-directory: ${{ github.workspace }}/outputs/test | |
run: Compress-Archive .\* ${{ github.workspace }}/windows.zip | |
- name: Upload a Build Artifact | |
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: 6.0.x | |
- name: Install zip | |
uses: montudor/action-zip@v1 | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Publish | |
run: dotnet publish --runtime "linux-x64" ./src/Azure/Csharp/CloudRepublic.BenchMark.SampleFunction/CloudRepublic.BenchMark.SampleFunction.csproj --output ./outputs/test --configuration "RELEASE" | |
- name: Debugging info | |
run: ls ./outputs/test | |
- name: Zip outputs | |
working-directory: ${{ github.workspace }}/outputs/test | |
run: zip -qq -r ${{ github.workspace }}/linux.zip . | |
- name: Upload a Build Artifact | |
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/CloudRepublic.BenchMark.SampleFunction/deployment.bicep --parameters prefix=${{ secrets.DEPLOYMENT_PREFIX }} --name csharp --deny-settings-mode None --delete-resources true --deny-settings-excluded-principals ${{ secrets.AZURE_OBJECTID }} | |
- name: Download Test Artifact Windows | |
uses: actions/download-artifact@v3.0.1 | |
with: | |
name: windows | |
path: ./outputs/test/windows | |
- name: Download Test Artifact Linux | |
uses: actions/download-artifact@v3.0.1 | |
with: | |
name: linux | |
path: ./outputs/test/linux | |
- 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 }}csharplin" | |
- 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 }}csharpwin" |