Skip to content
name: Publish Blazor App to GitHub Pages
on:
workflow_dispatch:
push:
paths:
- 'workshop/MyPortfolio/**'
# 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@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
- name: Set basepath on index.html
shell: pwsh
run: |
$filepath = "./src/MyPortfolio/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/MyPortfolio/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
}

Check failure on line 54 in .github/workflows/publish-gh-pages.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish-gh-pages.yml

Invalid workflow file

You have an error in your yaml syntax on line 54
- name: Restore NuGet packages
shell: bash
run: |
dotnet restore ./workshop
- name: Build solution
shell: bash
run: |
dotnet build ./workshop -c Release
- name: Test solution
shell: bash
run: |
dotnet test ./workshop -c Release
- name: Publish artifact
shell: bash
run: |
dotnet publish ./workshop/MyPortfolio -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