Skip to content

Commit 91cd499

Browse files
committed
Simplify .NET setup and streamline build workflow
Replaced manual .NET 10 SDK installation with `actions/setup-dotnet@v4` for easier setup. Added environment variables to configure .NET version, project path, and build settings. Introduced explicit `.NET Restore`, `.NET Build`, and `.NET Publish` steps for better control. Updated Azure Static Web App deployment to use the `publish/wwwroot` directory and skip redundant build steps. Removed `app_build_command` as the build process is now handled explicitly. These changes improve clarity, reduce complexity, and enhance maintainability of the workflow.
1 parent 384708b commit 91cd499

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

.github/workflows/azure-static-web-apps-calm-plant-04da70210.yml

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ jobs:
1313
build_and_deploy_job:
1414
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
1515
runs-on: ubuntu-latest
16+
env:
17+
DOTNET_VERSION: "net10.0"
18+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
19+
PROJECT: "BlazorBootstrap.Demo.WebAssembly/BlazorBootstrap.Demo.WebAssembly.csproj"
20+
BUILD_CONFIG: "Release"
1621

1722
name: Build and Deploy Job
1823
steps:
@@ -21,44 +26,37 @@ jobs:
2126
submodules: true
2227
lfs: false
2328

24-
- name: Cache .NET 10 SDK
25-
uses: actions/cache@v4
29+
# Setup .NET 10.0
30+
- name: Setup .NET 10.0
31+
uses: actions/setup-dotnet@v4
2632
with:
27-
path: $HOME/.dotnet
28-
key: dotnet-10-${{ runner.os }}-${{ hashFiles('**/global.json') }}
29-
restore-keys: |
30-
dotnet-10-${{ runner.os }}-
31-
32-
- name: Install .NET 10 SDK
33-
shell: bash
34-
run: |
35-
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
36-
chmod +x dotnet-install.sh
37-
# install latest 10.x channel; replace --version <exact-version> if needed
38-
./dotnet-install.sh --channel 10.0 --install-dir $HOME/.dotnet
39-
echo "$HOME/.dotnet" >> $GITHUB_PATH
40-
echo "DOTNET_ROOT=$HOME/.dotnet" >> $GITHUB_ENV
41-
- name: Verify dotnet
42-
run: dotnet --info
43-
44-
# # 1. Setup .NET 10 SDK
45-
# - name: Setup .NET
46-
# uses: actions/setup-dotnet@v4
47-
# with:
48-
# dotnet-version: '10.0.x'
33+
dotnet-version: '10.0.x'
4934

50-
# 2. Azure Static Web App Deployment Action
35+
# .NET Restore
36+
- name: .NET Restore
37+
run: dotnet restore ${{ env.PROJECT }}
38+
39+
# .NET Build
40+
- name: .NET Build
41+
run: dotnet build ${{ env.PROJECT }} -c ${{ env.BUILD_CONFIG }} -f ${{ env.DOTNET_VERSION }} --no-restore
42+
43+
# .NET Publish
44+
- name: .NET Publish
45+
run: dotnet publish ${{ env.PROJECT }} -c ${{ env.BUILD_CONFIG }} -o publish -f ${{ env.DOTNET_VERSION }} --no-build
46+
47+
# Azure Static Web App Deployment Action
5148
- name: Build And Deploy Blazor WASM App
5249
id: swa
5350
uses: azure/static-web-apps-deploy@v1
5451
with:
55-
dotnet-version: '10.0.x'
5652
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_CALM_PLANT_04DA70210 }}
5753
repo_token: ${{ secrets.GITHUB_TOKEN }}
5854
action: "upload"
59-
app_location: "BlazorBootstrap.Demo.WebAssembly" # App source code path
60-
output_location: "wwwroot" # Built app content directory - optional
61-
app_build_command: 'dotnet publish --configuration Release --output build'
55+
app_location: "publish/wwwroot"
56+
api_location: ""
57+
output_location: "publish/wwwroot"
58+
skip_api_build: true
59+
skip_app_build: true
6260

6361
close_pull_request_job:
6462
if: github.event_name == 'pull_request' && github.event.action == 'closed'

0 commit comments

Comments
 (0)