Skip to content

Commit 287ddae

Browse files
committed
fix-404
1 parent 4cc703e commit 287ddae

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

.github/workflows/test.yml

+38-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: ["main"]
88

99
jobs:
10-
test-non-main-repo:
10+
test-non-main-repo-fix-404:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout
@@ -22,9 +22,9 @@ jobs:
2222
project-path: Test/Test.csproj
2323
main-repo: false
2424
- name: Verify
25-
run: Test/Verify.sh --non-main-repo ${{ github.event.repository.name }}
25+
run: Test/Verify.sh --non-main-repo --fix-404 ${{ github.event.repository.name }}
2626

27-
test-main-repo:
27+
test-main-repo-fix-404:
2828
runs-on: ubuntu-latest
2929
steps:
3030
- name: Checkout
@@ -39,4 +39,38 @@ jobs:
3939
project-path: Test/Test.csproj
4040
main-repo: true
4141
- name: Verify
42-
run: Test/Verify.sh --main-repo ${{ github.event.repository.name }}
42+
run: Test/Verify.sh --main-repo --fix-404 ${{ github.event.repository.name }}
43+
44+
test-non-main-repo-no-fix-404:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
- name: Setup .NET
50+
uses: actions/setup-dotnet@v4
51+
with:
52+
dotnet-version: 8.0.x
53+
- name: GitHub Pages Blazor WASM
54+
uses: ./
55+
with:
56+
project-path: Test/Test.csproj
57+
main-repo: false
58+
- name: Verify
59+
run: Test/Verify.sh --non-main-repo --no-fix-404 ${{ github.event.repository.name }}
60+
61+
test-main-repo-no-fix-404:
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v4
66+
- name: Setup .NET
67+
uses: actions/setup-dotnet@v4
68+
with:
69+
dotnet-version: 8.0.x
70+
- name: GitHub Pages Blazor WASM
71+
uses: ./
72+
with:
73+
project-path: Test/Test.csproj
74+
main-repo: true
75+
- name: Verify
76+
run: Test/Verify.sh --main-repo --no-fix-404 ${{ github.event.repository.name }}

action.yml

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ inputs:
1313
main-repo:
1414
description: Set to true only when running this action from the default GitHub Pages repository ({ID}.github.io).
1515
default: false
16+
fix-404:
17+
description: Whether to apply repository-specific modifications to 404.html as well. This only takes effect when main-repo is false.
18+
default: true
1619
outputs:
1720
wwwroot-path:
1821
description: Path of wwwroot
@@ -42,6 +45,11 @@ runs:
4245
run: sed -i 's/base href="\/"/base href="\/${{ github.event.repository.name }}\/"/g' ${{ steps.wwwroot-output.outputs.wwwroot }}/index.html
4346
shell: bash
4447

48+
- name: Modify 404.html for this repository
49+
if: ${{ inputs.main-repo == 'false' && inputs.fix-404 == 'true' }}
50+
run: sed -i 's/\/?p=\//\/${{ github.event.repository.name }}\/?p=\//g' ${{ steps.wwwroot-output.outputs.wwwroot }}/404.html
51+
shell: bash
52+
4553
- name: Create .nojekyll
4654
run: touch ${{ steps.wwwroot-output.outputs.wwwroot }}/.nojekyll
4755
shell: bash

0 commit comments

Comments
 (0)