Simplify and modernize CI/CD workflow #556
This file contains hidden or 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: Static WebApp (Blazor WebAssembly) | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: [opened, synchronize, reopened, closed] | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| prod_release: | |
| description: 'Do you want to release to production?' | |
| required: true | |
| default: false | |
| type: boolean | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| env: | |
| DOTNET_TELEMETRY_OPTOUT: '1' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Show dotnet version | |
| run: dotnet --info | |
| - name: Clean repository build outputs | |
| run: | | |
| dotnet clean | |
| rm -rf **/obj **/bin | |
| - name: Update workloads (required for wasm/Emscripten) | |
| run: dotnet workload update --no-restore | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Publish Blazor WebAssembly (CI-mode) | |
| run: | | |
| dotnet publish BlazorBootstrap.Demo.WebAssembly/BlazorBootstrap.Demo.WebAssembly.csproj -c Release -o build/publish -v minimal | |
| - name: Archive published build | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: published-webassembly-build | |
| path: build/publish | |
| - name: Deploy to Azure Static Web Apps | |
| uses: Azure/static-web-apps-deploy@v1 | |
| with: | |
| azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| action: "upload" | |
| app_location: "/" | |
| api_location: "" | |
| output_location: "build/publish" | |
| deployment_environment: ${{ github.event.inputs.prod_release == 'true' && 'production' || 'staging' }} |