|
| 1 | +name: Azure Static Web Apps CI/CD |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + types: [opened, synchronize, reopened, closed] |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +jobs: |
| 13 | + build_and_deploy_job: |
| 14 | + env: |
| 15 | + DIST_PATH: samples/WinUI.TableView.SampleApp.Uno/bin/Release/net10.0-browserwasm/publish/wwwroot |
| 16 | + DotnetVersion: '10.0.100' |
| 17 | + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') |
| 18 | + runs-on: ubuntu-latest |
| 19 | + container: 'unoplatform/wasm-build:3.0' |
| 20 | + name: Build and Deploy Job |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v3 |
| 23 | + with: |
| 24 | + submodules: true |
| 25 | + lfs: false |
| 26 | + |
| 27 | + # When running on macos, set the DOTNET_INSTALL_DIR so a workspace local folder |
| 28 | + # is used to install the SDK. This is required for the Uno.Sdk.Updater to work |
| 29 | + - name: Set DOTNET_INSTALL_DIR |
| 30 | + if: runner.os == 'macos' || runner.os == 'linux' |
| 31 | + shell: bash |
| 32 | + run: echo "DOTNET_INSTALL_DIR=$GITHUB_WORKSPACE/.dotnet" >> $GITHUB_ENV |
| 33 | + |
| 34 | + - name: 'Set Wasm cache path' |
| 35 | + shell: pwsh |
| 36 | + run: echo "WasmCachePath=${{ github.workspace }}/.emscripten-cache" >> $env:GITHUB_ENV |
| 37 | + |
| 38 | + - name: Cache EMSDK |
| 39 | + id: cache-emsdk |
| 40 | + uses: actions/cache@v4 |
| 41 | + env: |
| 42 | + cache-name: cache-emsdk-modules |
| 43 | + with: |
| 44 | + path: ${{ env.WasmCachePath }} |
| 45 | + key: ${{ runner.os }}-build-emsdk-${{ env.ValidationUnoCheckVersion }} |
| 46 | + restore-keys: | |
| 47 | + ${{ runner.os }}-build-emsdk-${{ env.ValidationUnoCheckVersion }} |
| 48 | +
|
| 49 | + - name: Cache .NET |
| 50 | + id: cache-dotnet |
| 51 | + uses: actions/cache@v4 |
| 52 | + env: |
| 53 | + cache-name: cache-dotnet-install |
| 54 | + with: |
| 55 | + path: ${{ github.workspace }}/.dotnet |
| 56 | + key: ${{ runner.os }}-build-dotnet-${{ env.DotnetVersion }} |
| 57 | + restore-keys: | |
| 58 | + ${{ runner.os }}-build-dotnet-${{ env.DotnetVersion }} |
| 59 | +
|
| 60 | + - name: Setup .NET |
| 61 | + uses: actions/setup-dotnet@v1.7.2 |
| 62 | + with: |
| 63 | + dotnet-version: ${{ env.DotnetVersion }} |
| 64 | + |
| 65 | + - uses: dotnet/nbgv@f088059084cb5d872e9d1a994433ca6440c2bf72 # v0.4.2 |
| 66 | + id: nbgv |
| 67 | + with: |
| 68 | + toolVersion: 3.6.139 |
| 69 | + setAllVars: true |
| 70 | + |
| 71 | + - run: | |
| 72 | + cd samples/WinUI.TableView.SampleApp.Uno |
| 73 | + dotnet workload restore |
| 74 | + name: Setup Workloads |
| 75 | +
|
| 76 | + - run: | |
| 77 | + cd samples/WinUI.TableView.SampleApp.Uno |
| 78 | + dotnet workload install wasm-tools |
| 79 | + name: Setup Workloads |
| 80 | +
|
| 81 | + - run: | |
| 82 | + cd samples/WinUI.TableView.SampleApp.Uno |
| 83 | + dotnet publish -c Release -f net10.0-browserwasm "/p:PackageVersion=${{ steps.nbgv.outputs.SemVer2 }}" /p:EnableWindowsTargeting=true /bl:../binlogs/output.binlog |
| 84 | + name: Build Uno Wasm App |
| 85 | +
|
| 86 | + - uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: wasm-site |
| 89 | + path: ${{ env.DIST_PATH }} |
| 90 | + |
| 91 | + - uses: actions/upload-artifact@v4 |
| 92 | + with: |
| 93 | + name: logs |
| 94 | + path: binlogs |
| 95 | + |
| 96 | + - name: Build And Deploy |
| 97 | + id: builddeploy |
| 98 | + continue-on-error: true |
| 99 | + uses: Azure/static-web-apps-deploy@v1 |
| 100 | + with: |
| 101 | + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LIVELY_GROUND_0D0F6A810 }} |
| 102 | + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) |
| 103 | + action: "upload" |
| 104 | + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### |
| 105 | + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig |
| 106 | + app_location: "${{ env.DIST_PATH }}" # App source code path |
| 107 | + api_location: "" # Api source code path - optional |
| 108 | + output_location: "" # Built app content directory - optional |
| 109 | + ###### End of Repository/Build Configurations ###### |
| 110 | + |
| 111 | + close_pull_request_job: |
| 112 | + if: github.event_name == 'pull_request' && github.event.action == 'closed' |
| 113 | + runs-on: ubuntu-latest |
| 114 | + name: Close Pull Request Job |
| 115 | + steps: |
| 116 | + - name: Close Pull Request |
| 117 | + id: closepullrequest |
| 118 | + uses: Azure/static-web-apps-deploy@v1 |
| 119 | + with: |
| 120 | + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LIVELY_GROUND_0D0F6A810 }} |
| 121 | + action: "close" |
| 122 | + |
| 123 | + |
0 commit comments