Skip to content

Commit ab3f2e0

Browse files
committed
Simplify and modernize CI/CD workflow
- Rename `build_and_deploy_job` to `build-and-deploy` for consistency. - Remove `if` condition to simplify job triggering logic. - Add `DOTNET_TELEMETRY_OPTOUT` to disable .NET telemetry. - Downgrade `actions/checkout` to v4 and `actions/setup-dotnet` to v4. - Replace WASM workload install with `dotnet workload update`. - Add step to clean repository build outputs (`dotnet clean`). - Update `dotnet publish` to specify project file and output path. - Remove debugging steps for build output structure. - Update `Azure/static-web-apps-deploy` with new parameters: - Set `app_location` to `/` and `output_location` to `build/publish`. - Dynamically determine `deployment_environment` (production/staging). - Remove `close_pull_request_job` to simplify workflow. - Add `actions/upload-artifact` to archive published build output. - Use `AZURE_STATIC_WEB_APPS_API_TOKEN` secret for deployment.
1 parent 27fee72 commit ab3f2e0

File tree

1 file changed

+31
-44
lines changed

1 file changed

+31
-44
lines changed

.github/workflows/static-web-app.yml

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,64 +17,51 @@ on:
1717
type: boolean
1818

1919
jobs:
20-
build_and_deploy_job:
21-
# Run when:
22-
# - workflow_dispatch AND prod_release == true
23-
# - OR pull_request (except when closed)
24-
if: >
25-
(github.event_name == 'workflow_dispatch' && github.event.inputs.prod_release == 'true') ||
26-
(github.event_name == 'pull_request' && github.event.action != 'closed')
20+
build-and-deploy:
2721
runs-on: ubuntu-latest
28-
name: Build and Deploy Job
22+
env:
23+
DOTNET_TELEMETRY_OPTOUT: '1'
24+
2925
steps:
30-
- uses: actions/checkout@v5
31-
with:
32-
submodules: true
26+
- name: Checkout
27+
uses: actions/checkout@v4
3328

3429
- name: Setup .NET SDK
35-
uses: actions/setup-dotnet@v5
30+
uses: actions/setup-dotnet@v4
3631
with:
3732
dotnet-version: '10.0.x'
3833

39-
- name: Install WASM workload
40-
run: dotnet workload install wasm-tools --skip-manifest-update
34+
- name: Show dotnet version
35+
run: dotnet --info
36+
37+
- name: Clean repository build outputs
38+
run: |
39+
dotnet clean
40+
rm -rf **/obj **/bin
41+
42+
- name: Update workloads (required for wasm/Emscripten)
43+
run: dotnet workload update --no-restore
4144

4245
- name: Restore
4346
run: dotnet restore
4447

45-
- name: Publish app (produce static assets)
46-
run: dotnet publish BlazorBootstrap.Demo.WebAssembly -c Release -o build
47-
48-
- name: Show published files (debug)
48+
- name: Publish Blazor WebAssembly (CI-mode)
4949
run: |
50-
echo "repo root tree (top-level):"
51-
ls -la .
52-
echo "build folder tree:"
53-
ls -la build || true
54-
echo "build/wwwroot tree:"
55-
ls -la build/wwwroot || true
56-
echo "index.html exists?"
57-
if [ -f build/wwwroot/index.html ]; then echo "FOUND"; else echo "MISSING"; fi
50+
dotnet publish BlazorBootstrap.Demo.WebAssembly/BlazorBootstrap.Demo.WebAssembly.csproj -c Release -o build/publish -v minimal
5851
59-
- name: Build And Deploy (upload artifacts; skip Oryx build)
60-
id: builddeploy
61-
uses: Azure/static-web-apps-deploy@v1
52+
- name: Archive published build
53+
uses: actions/upload-artifact@v4
6254
with:
63-
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GRAY_WAVE_0E4848710 }}
64-
repo_token: ${{ secrets.GITHUB_TOKEN }}
65-
action: "upload"
66-
app_location: "." # repository root
67-
skip_app_build: true # we already produced the build on runner
68-
app_artifact_location: "build/wwwroot" # <-- IMPORTANT: point to the published static files
55+
name: published-webassembly-build
56+
path: build/publish
6957

70-
close_pull_request_job:
71-
if: github.event_name == 'pull_request' && github.event.action == 'closed'
72-
runs-on: ubuntu-latest
73-
name: Close Pull Request Job
74-
steps:
75-
- name: Close Pull Request
76-
id: closepullrequest
58+
- name: Deploy to Azure Static Web Apps
7759
uses: Azure/static-web-apps-deploy@v1
7860
with:
79-
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GRAY_WAVE_0E4848710 }}
80-
action: "close"
61+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
62+
repo_token: ${{ secrets.GITHUB_TOKEN }}
63+
action: "upload"
64+
app_location: "/"
65+
api_location: ""
66+
output_location: "build/publish"
67+
deployment_environment: ${{ github.event.inputs.prod_release == 'true' && 'production' || 'staging' }}

0 commit comments

Comments
 (0)