From 98770145129751e3c560b84a0dd442dbd775a367 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Mon, 24 Jul 2023 18:02:22 +0800 Subject: [PATCH] feat: github pages. --- .github/workflows/deploy.yml | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..bcd5bde --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,50 @@ +name: Deploy to GitHub Pages + +env: + PROJECT_PATH: demo/Semi.Avalonia.Demo.Web/Semi.Avalonia.Demo.Web.csproj + OUTPUT_PATH: demo/Semi.Avalonia.Demo.Web/bin/Debug/net7.0/browser-wasm/AppBundle +on: + push: + branches: [ "deploy" ] + pull_request: + branches: [ "deploy" ] + +jobs: + deploy-to-github-pages: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup .NET Core SDK + uses: actions/setup-dotnet@v1.9.0 + + - name: Install wasm-tools + run: dotnet workload install wasm-tools wasm-experimental + + - name: Install DotNetCompress + run: dotnet tool install --global DotNetCompress --version 2.0.0 --no-cache + + - name: Publish .NET Project + run: dotnet publish $PROJECT_PATH -c Debug -o debug --nologo + + - name: Change base-tag in index.html + run: sed -i 's///g' $OUTPUT_PATH/index.html + + - name: copy index.html to 404.html + run: cp $OUTPUT_PATH/index.html $OUTPUT_PATH/404.html + + - name: Compress Output using Brotli + run: DotNetCompress -d $OUTPUT_PATH -p "*.dll" "*.js" "*.wasm" --format br --threads 4 + + - name: Compress Output using GZip + run: DotNetCompress -d $OUTPUT_PATH -p "*.dll" "*.js" "*.wasm" --format gz --threads 4 + + - name: Add .nojekyll file + run: touch $OUTPUT_PATH/.nojekyll + + - name: Commit wwwroot to GitHub Pages + uses: JamesIves/github-pages-deploy-action@4.1.7 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: ${{ env.OUTPUT_PATH }}