Skip to content

Hot reload support. #27 #60

Hot reload support. #27

Hot reload support. #27 #60

name: Build, publish to gh pages and nuget
on:
push:
branches: ["*"]
env:
WEBAPP_PATH: BlazorStaticWebsite
NUGET_PKG_PATH: src/bin/Release
WEBAPP_CSPROJ: BlazorStaticWebsite.csproj
ASPNETCORE_ENVIRONMENT: Production
jobs:
build:
runs-on: ubuntu-latest
outputs:
webapp-path: ${{ env.WEBAPP_PATH }}
steps:
- uses: actions/checkout@v4
- name: Remove launchSettings.json (to not override ASPNETCORE_ENVIRONMENT)
run: rm ${{ env.WEBAPP_PATH }}/Properties/launchSettings.json
- name: Tailwind - download and run cli
run: |
wget https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 -O /usr/local/bin/tailwindcss
chmod +x /usr/local/bin/tailwindcss
cd ${{ env.WEBAPP_PATH }}
tailwindcss --input ./wwwroot/app.css --output ./wwwroot/app.min.css --minify
- name: Change <base href="" /> in App.razor to match gh repo name
run: |
REPO_NAME=$(echo "${{ github.repository }}" | awk -F '/' '{print $NF}')
sed -i 's/<base href="\/" \/>/<base href="\/'$REPO_NAME'\/" \/>/g' ${{ env.WEBAPP_PATH }}/Components/App.razor
- name: Run webapp and generate static files
run: dotnet run --project ${{ env.WEBAPP_PATH }}/${{env.WEBAPP_CSPROJ}} --configuration Release
- name: Upload webapp output artifacts
uses: actions/upload-artifact@v3
with:
name: static-pages-output
path: ${{ env.WEBAPP_PATH }}/output
- name: Upload NuGet package artifacts
if: github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: ${{ env.NUGET_PKG_PATH }}/*.nupkg
deploy-to-gh-pages:
permissions:
contents: write
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: static-pages-output
path: output
- run: touch output/.nojekyll #folder starting with _ are handled as jekyll. This file will prevent that.
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./output
publish-to-nuget:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Download NuGet package artifacts
uses: actions/download-artifact@v4
with:
name: nuget-packages
- name: Publish to NuGet
run: |
dotnet nuget push "*.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate