Skip to content

Update GitHub Pages deployment workflow #14

Update GitHub Pages deployment workflow

Update GitHub Pages deployment workflow #14

name: Deploy to GitHub Pages
env:
PUBLISH_DIR: src/Blazor.Client.HelloWorld/bin/Release/net8.0/publish/wwwroot
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.x'
- name: Publish app
run: dotnet publish ./src/Blazor.Client.HelloWorld/Blazor.Client.HelloWorld.csproj -c Release
- name: Rewrite base href
uses: SteveSandersonMS/ghaction-rewrite-base-href@v1
with:
html_path: ${{ env.PUBLISH_DIR }}/index.html
base_href: /github-sample/
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: published-app
path: ${{ env.PUBLISH_DIR }}
deploy:
runs-on: ubuntu-latest
needs: build
permissions:
pages: write
id-token: write
actions: read
environment:
name: github-pages
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: published-app
path: ./wwwroot
- name: GitHub Pages
if: success()
uses: crazy-max/ghaction-github-pages@v1.5.1
with:
target_branch: gh-pages
build_dir: ./wwwroot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update environment
run: echo "PAGE_URL=https://${{ github.repository_owner }}.github.io/${{ github.repository }}" >> $GITHUB_ENV