91 lines
2.2 KiB
YAML
91 lines
2.2 KiB
YAML
name: Publish Blazor App to GitHub Pages
|
|
|
|
on: [ push, workflow_dispatch ]
|
|
|
|
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
permissions:
|
|
contents: write
|
|
pages: write
|
|
id-token: write
|
|
|
|
# Allow one concurrent deployment
|
|
concurrency:
|
|
group: "pages"
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build_test_artifact:
|
|
name: Build App
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup .NET SDK
|
|
uses: actions/setup-dotnet@v2
|
|
with:
|
|
dotnet-version: '7.x'
|
|
|
|
# - name: Set basepath on index.html
|
|
# shell: pwsh
|
|
# run: |
|
|
# $filepath = "./src/BlazorApp/wwwroot/index.html"
|
|
# $repository = "${{ github.repository }}" -replace "${{ github.repository_owner }}", ""
|
|
|
|
# $html = Get-Content -Path $filepath
|
|
# $html -replace "<base href=`"/`" />", "<base href=`"$repository/`" />" | Out-File -Path $filepath -Force
|
|
|
|
# - name: Set basepath on JSON objects
|
|
# shell: pwsh
|
|
# run: |
|
|
# $filepath = "./src/BlazorApp/wwwroot/sample-data"
|
|
# $repository = "${{ github.repository }}" -replace "${{ github.repository_owner }}", ""
|
|
|
|
# Get-ChildItem -Path $filepath -Filter "*.json" | ForEach-Object {
|
|
# $json = Get-Content -Path $_.FullName
|
|
# $json.Replace("../", "$repository/") | Out-File -Path $_.FullName -Force
|
|
# }
|
|
|
|
- name: Restore NuGet packages
|
|
shell: bash
|
|
run: |
|
|
dotnet restore .
|
|
|
|
- name: Build solution
|
|
shell: bash
|
|
run: |
|
|
dotnet build .
|
|
|
|
- name: Test solution
|
|
shell: bash
|
|
run: |
|
|
dotnet test . -c Release
|
|
|
|
- name: Publish artifact
|
|
shell: bash
|
|
run: |
|
|
dotnet publish src/BlazorApp -c Release -o published
|
|
|
|
- name: Upload artifact for web
|
|
uses: actions/upload-pages-artifact@v1
|
|
with:
|
|
path: published/wwwroot
|
|
|
|
deploy:
|
|
name: Deploy App to GitHub Pages
|
|
needs:
|
|
- build_test_artifact
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v1
|