Skip to content

πŸ“ Adding Blazor SSR deployment scripts #1

πŸ“ Adding Blazor SSR deployment scripts

πŸ“ Adding Blazor SSR deployment scripts #1

Workflow file for this run

name: Blazor SSR Site
on:
# Triggers the workflow on push or pull request events but only for the 'main' branch
push:
paths-ignore:
- "src/AnimeFeedManager.Web**"
- "src/AnimeFeedManager.Functions"
- "**/*.md"
branches:
- main
pull_request:
paths-ignore:
- "src/AnimeFeedManager.Web**"
- "src/AnimeFeedManager.Functions"
- "**/*.md"
types: [opened, synchronize, reopened, closed]
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
APP_PATH: "./src/AnimeFeedManager.Web"
AZURE_WEBAPP_PACKAGE_PATH: "." # set this to the path to your web app project, defaults to the repository root
DOTNET_VERSION: "8.0.x" # set this to the dot net version to use
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout the repo
- uses: actions/checkout@main
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
# Deploys infrastructure
- name: Deploy Azure Infrastructure
uses: Azure/arm-deploy@v1
id: infrastructure
with:
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }}
resourceGroupName: ${{ secrets.AZURE_RG }}
template: ./deployment/main-blazor.bicep
parameters: passwordlessApiKey=${{ secrets.PASSWORDLESS_APIKEY }} passwordlessApiSecret=${{ secrets.PASSWORDLESS_APISECRET }}
failOnStdErr: false
- name: "Set Output as Env Var"
run: echo "AZURE_WEBAPP_NAME=${{ steps.infrastructure.outputs.appname }}" >> $GITHUB_ENV
# Setup node.js for tailwind
- name: Setup Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: "npm install, build, and test"
run: |
npm install
npx tailwindcss -i ./Styles/app.css -o ./wwwroot/app.css --minify
working-directory: APP_PATH
# Setup .NET Core SDK
- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
# Run dotnet build and publish
- name: dotnet build and publish
shell: bash
run: |
pushd '${{ env.APP_PATH }}'
dotnet restore
dotnet build --configuration Release
dotnet publish -c Release --property:PublishDir='${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp'
popd
# Deploy to Azure Web apps
- name: "Run Azure webapp deploy action using publish profile credentials"
uses: azure/webapps-deploy@v3
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name
package: "${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp"
- name: logout
run: |
az logout