Sales module demo CD #13
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
name: Sales module demo CD | |
# Project templates come equipped with CI/CD for both Azure DevOps and GitHub, providing you with a hassle-free way to get started with your new project. It is important to note that you should not depend on the contents of this file. More info at https://bitplatform.dev/templates/dev-ops | |
env: | |
SERVER_ADDRESS: 'https://sales.bitplatform.dev' | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build_api_blazor: | |
name: build api + blazor web | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: src/global.json | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 23 | |
- name: Create project from Boilerplate | |
run: | | |
cd src/Templates/Boilerplate && dotnet build -c Release | |
dotnet pack -c Release -o . -p:ReleaseVersion=0.0.0 -p:PackageVersion=0.0.0 | |
dotnet new install Bit.Boilerplate.0.0.0.nupkg | |
cd ../../../ && dotnet new bit-bp --name SalesModule --database PostgreSQL --module Sales --appInsights --apiServerUrl ${{ env.SERVER_ADDRESS }} --webAppUrl ${{ env.SERVER_ADDRESS }} --filesStorage AzureBlobStorage --notification --captcha reCaptcha --framework net9.0 | |
- name: Update core appsettings.json | |
uses: devops-actions/[email protected] | |
with: | |
files: 'SalesModule/src/Shared/appsettings.json, SalesModule/src/Client/SalesModule.Client.Core/appsettings.json, SalesModule/src/Client/SalesModule.Client.Web/appsettings.json, SalesModule/src/Client/SalesModule.Client.Web/appsettings.Production.json' | |
env: | |
WebAppRender.PrerenderEnabled: true | |
ServerAddress: / | |
WebAppRender.BlazorMode: BlazorWebAssembly | |
AdsPushVapid.PublicKey: ${{ secrets.SALES_PUBLIC_VAPIDKEY }} | |
GoogleRecaptchaSiteKey: ${{ secrets.GOOGLE_RECAPTCHA_SITE_KEY }} | |
ApplicationInsights.ConnectionString: ${{ secrets.APPLICATION_INSIGHTS_CONNECTION_STRING }} | |
- name: Install wasm | |
run: cd src && dotnet workload install wasm-tools | |
- name: Configure bswup | |
run: | | |
sed -i 's/\/\/ self.disablePassiveFirstBoot/self.disablePassiveFirstBoot/g' SalesModule/src/Client/SalesModule.Client.Web/wwwroot/service-worker.published.js | |
- name: Generate CSS/JS files | |
run: dotnet build SalesModule/src/Client/SalesModule.Client.Core/SalesModule.Client.Core.csproj -t:BeforeBuildTasks -p:Version="${{ vars.APPLICATION_DISPLAY_VERSION}}" -p:MultilingualEnabled=false --no-restore -c Release | |
- name: Publish | |
run: dotnet publish SalesModule/src/Server/SalesModule.Server.Web/SalesModule.Server.Web.csproj -c Release -p:PwaEnabled=true --self-contained -r linux-x64 -o ${{env.DOTNET_ROOT}}/server -p:Version="${{ vars.APPLICATION_DISPLAY_VERSION}}" -p:MultilingualEnabled=false | |
- name: Upload server artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: server-bundle | |
path: ${{env.DOTNET_ROOT}}/server | |
include-hidden-files: true # Required for wwwroot/.well-known folder | |
deploy_api_blazor: | |
name: deploy api + blazor | |
needs: build_api_blazor | |
runs-on: ubuntu-24.04 | |
environment: | |
name: 'production' | |
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
steps: | |
- name: Retrieve server bundle | |
uses: actions/download-artifact@v4 | |
with: | |
name: server-bundle | |
- name: Delete DataProtectionCertificate.pfx | |
run: | | |
rm DataProtectionCertificate.pfx | |
- name: Extract identity certificate from env | |
uses: timheuer/[email protected] | |
with: | |
fileDir: './' | |
fileName: 'DataProtectionCertificate.pfx' | |
encodedString: ${{ secrets.API_DATA_PROTECTION_CERTIFICATE_FILE_BASE64 }} | |
# - name: Retrieve AppleAuthKey.p8 | |
# run: echo "${{ secrets.APPSTORE_API_KEY_PRIVATE_KEY_SALES }}" > AppleAuthKey.p8 | |
- name: Deploy to Azure Web App | |
id: deploy-to-webapp | |
uses: azure/webapps-deploy@v3 | |
with: | |
app-name: 'bit-sales' | |
slot-name: 'production' | |
publish-profile: ${{ secrets.SALES_AZURE_APP_SERVICE_PUBLISH_PROFILE }} | |
package: . | |
- name: Purge cache | |
uses: jakejarvis/[email protected] | |
env: | |
CLOUDFLARE_ZONE: ${{ secrets.BITPLATFORM_DEV_CLOUDFLARE_ZONE }} | |
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }} |