Skip to content

Merge pull request #175 from mark-szabo/v2.4 #25

Merge pull request #175 from mark-szabo/v2.4

Merge pull request #175 from mark-szabo/v2.4 #25

Workflow file for this run

name: Build and deploy to PROD
on:
push:
branches:
- main
env:
AZURE_WEBAPP_NAME: mimosonk
AZURE_WEBAPP_PACKAGE_PATH: CarWash.PWA\publish
AZURE_RESOURCE_GROUP: rg-carwash-mimosonk-prod
AZURE_APPCONFIG_NAME: appcs-carwash-mimosonk-prod
AZURE_APPCONFIG_ENDPOINT: https://appcs-carwash-mimosonk-prod.azconfig.io
AZURE_CDN_PROFILE_NAME: cdnp-carwash-mimosonk-prod
AZURE_CDN_ENDPOINT: cdne-carwash-mimosonk-prod
CONFIGURATION: Release
DOTNET_CORE_VERSION: 8.0.x
WORKING_DIRECTORY: CarWash.PWA
jobs:
build:
runs-on: windows-latest
outputs:
build_number: ${{ steps.build_number.outputs.VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
- name: Read version number from package.json
id: build_number
run: echo "VERSION=$(cat ${{ env.WORKING_DIRECTORY }}/ClientApp/package.json | jq '.version')" >> $env:GITHUB_OUTPUT
- name: Create .env file with build number
run: echo "REACT_APP_BUILD_NUMBER=${{ steps.build_number.outputs.VERSION }}" > ${{ env.WORKING_DIRECTORY }}/.env
- name: Restore
run: dotnet restore "${{ env.WORKING_DIRECTORY }}"
- name: Build
env:
VERSION: ${{ steps.build_number.outputs.VERSION }}
run: dotnet build "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-restore
- name: Test
run: dotnet test "CarWash.PWA.Tests" --collect:"XPlat Code Coverage"
- name: Report code coverage
uses: codecov/codecov-action@v2
with:
files: ./CarWash.PWA.Tests/TestResults/**/*.xml
flags: unittests
name: codecov-umbrella
- name: Publish
run: dotnet publish "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-build --output "${{ env.AZURE_WEBAPP_PACKAGE_PATH }}"
- name: Publish Artifacts
uses: actions/upload-artifact@v3
with:
name: webapp
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
deploy:
runs-on: windows-latest
needs: build
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: webapp
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: Deploy to Azure WebApp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.mimosonk_E838 }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: Azure service principal login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Update app configuration VERSION
run: |
az appconfig kv set `
--name ${{ env.AZURE_APPCONFIG_NAME }} `
--auth-mode login `
--endpoint ${{ env.AZURE_APPCONFIG_ENDPOINT }} `
--key VERSION `
--value ${{ needs.build.outputs.build_number }} `
--yes
- name: Purge Azure CDN endpoint
run: |
az cdn endpoint purge `
--resource-group ${{ env.AZURE_RESOURCE_GROUP }} `
--profile-name ${{ env.AZURE_CDN_PROFILE_NAME }} `
--name ${{ env.AZURE_CDN_ENDPOINT }} `
--content-paths '/' '/sw.js' '/api/.well-known/configuration' `
--no-wait
- name: Azure service principal logout
run: az logout