Skip to content

Commit b7d37f6

Browse files
committed
Revamp SWA workflow and simplify static asset exclusions
Replaces the old Azure Static Web Apps workflow with a modernized version featuring explicit .NET 10.0 setup, granular build steps, and support for manual dispatch. Deployment now uploads pre-built Blazor WASM output. Also simplifies staticwebapp.config.json by reducing navigationFallback exclusions, allowing more static assets to be served via fallback.
1 parent fd2751b commit b7d37f6

3 files changed

Lines changed: 80 additions & 54 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: AzureStaticWebApp (Blazor WebAssembly)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened, closed]
9+
branches:
10+
- main
11+
workflow_dispatch:
12+
inputs:
13+
prod_release:
14+
description: 'Do you want to release to production?'
15+
required: true
16+
default: false
17+
type: boolean
18+
19+
jobs:
20+
build_and_deploy_job:
21+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
22+
runs-on: ubuntu-latest
23+
env:
24+
DOTNET_VERSION: "net10.0"
25+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
26+
PROJECT: "BlazorExpress.ChartJS.Demo.WebAssembly/BlazorExpress.ChartJS.Demo.WebAssembly.csproj"
27+
BUILD_CONFIG: "Release"
28+
29+
name: Build and Deploy Job
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
submodules: true
34+
lfs: false
35+
36+
# Setup .NET 10.0
37+
- name: Setup .NET 10.0
38+
uses: actions/setup-dotnet@v4
39+
with:
40+
dotnet-version: '10.0.x'
41+
42+
# .NET Restore
43+
- name: .NET Restore
44+
run: dotnet restore ${{ env.PROJECT }}
45+
46+
# .NET Build
47+
- name: .NET Build
48+
run: dotnet build ${{ env.PROJECT }} -c ${{ env.BUILD_CONFIG }} -f ${{ env.DOTNET_VERSION }} --no-restore
49+
50+
# .NET Publish
51+
- name: .NET Publish
52+
run: dotnet publish ${{ env.PROJECT }} -c ${{ env.BUILD_CONFIG }} -o output -f ${{ env.DOTNET_VERSION }} --no-build
53+
54+
55+
# Azure Static Web App Deployment Action
56+
- name: Build And Deploy Blazor WASM App
57+
id: swa
58+
uses: Azure/static-web-apps-deploy@v1
59+
with:
60+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WITTY_FOREST_0C3A9ED10 }}
61+
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
62+
action: "upload"
63+
app_location: "output/wwwroot"
64+
api_location: ""
65+
output_location: "output/wwwroot"
66+
skip_api_build: true
67+
skip_app_build: true
68+
69+
close_pull_request_job:
70+
if: github.event_name == 'pull_request' && github.event.action == 'closed'
71+
runs-on: ubuntu-latest
72+
name: Close Pull Request Job
73+
steps:
74+
- name: Close Pull Request
75+
id: closepullrequest
76+
uses: Azure/static-web-apps-deploy@v1
77+
with:
78+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WITTY_FOREST_0C3A9ED10 }}
79+
action: "close"

.github/workflows/azure-static-web-apps-witty-forest-0c3a9ed10.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
{
22
"navigationFallback": {
33
"rewrite": "/index.html",
4-
"exclude": [
5-
"/_framework/*",
6-
"/_content/*",
7-
"/images/*.{png,jpg,gif}",
8-
"/css/*",
9-
"/js/*",
10-
"*.{png,jpg,gif,ico,webp,svg,wasm}"
11-
]
4+
"exclude": [ "/images/*.{png,jpg,gif}", "/css/*" ]
125
}
136
}

0 commit comments

Comments
 (0)