Skip to content

Commit da07d46

Browse files
committed
readme
1 parent 1cb26f6 commit da07d46

File tree

2 files changed

+73
-23
lines changed

2 files changed

+73
-23
lines changed

README.md

+73-23
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,59 @@
22

33
This action allows you to deploy your Blazor WASM app to GitHub Pages.
44

5+
## Table of Contents
6+
- [What this does](#what-this-does)
7+
- [How to use](#how-to-use)
8+
- [1. Set the Project](#1-set-the-project)
9+
- [2. Set the repository settings](#2-set-the-repository-settings)
10+
- [3. Add workflow file](#3-add-workflow-file)
11+
- [Inputs and Outputs](#inputs-and-outputs)
12+
- [Inputs](#inputs)
13+
- [Outputs](#outputs)
14+
- [Troubleshooting](#troubleshooting)
15+
516
## What this does
617

7-
Restore, build, and publish the project, modify index.html to fit the
8-
repository, and create a .nojekyll file.
18+
Restore, build, and publish the project, modify index.html and 404.html to fit the repository.
919

1020
## How to use
1121

12-
First, set Repository Settings - Pages - Source to GitHub Actions.
22+
### 1. Set the Project
1323

14-
This action has four inputs and one output.
24+
Add [`Bluehill.Blazor.GHPages` NuGet Package](https://www.nuget.org/packages/Bluehill.Blazor.GHPages/) to the project.
25+
This Package adds `gh-pages.js` and `404.html` to the published `wwwroot` directory. If these files already exist,
26+
delete them.
1527

16-
### Inputs
28+
Modify `index.html` to include the `gh-pages.js` script. This script adjusts routing for Blazor WebAssembly apps
29+
deployed to GitHub Pages, ensuring the app behaves correctly when navigating subpages.
30+
31+
```html
32+
<script src="gh-pages.js"></script>
33+
<script src="_framework/blazor.webassembly.js"></script>
34+
```
1735

18-
`project-path`: Path of project (.csproj). Default is
19-
`(repo name)/(repo name).csproj`.
36+
### 2. Set the repository settings
2037

21-
`publish-path`: Path to output in Publish step. It doesn't matter most of the
22-
time.
38+
Go to your repository's **Settings > Pages > Source** and set the source to **GitHub Actions**.
2339

24-
`main-repo`: Set to `true` only when running this action from the default GitHub
25-
Pages repository (`{username}.github.io`).
40+
This step is crucial for enabling deployments using the GitHub Pages workflow. For reference:
2641

27-
`fix-404`: Whether to apply repository-specific modifications to 404.html as
28-
well. This only takes effect when main-repo is false. Default is `true`.
42+
![image1](./image1.png)
2943

30-
### Outputs
44+
### 3. Add workflow file
3145

32-
`wwwroot-path`: The resulting `wwwroot` path. It must be passed to `path` in the
33-
`upload-pages-artifact` step.
46+
Below is an example workflow that deploys your Blazor WebAssembly app to GitHub Pages. Copy these into
47+
`.github/workflows/gh-pages.yml` in your repository.
3448

35-
## Example Workflow
49+
> **Replace `MyBlazorApp/MyBlazorApp.csproj` with your actual `.csproj` path.**
3650
3751
```yml
38-
name: Deploy
52+
name: Deploy GitHub Pages
3953

4054
on:
4155
# Runs on pushes targeting the default branch
4256
push:
43-
branches: ["main"]
57+
branches: [ "main" ]
4458

4559
# Allows you to run this workflow manually from the Actions tab
4660
workflow_dispatch:
@@ -67,13 +81,12 @@ jobs:
6781
- name: Setup .NET
6882
uses: actions/setup-dotnet@v4
6983
with:
70-
dotnet-version: 8.0.x
84+
dotnet-version: 9.0.x
7185
- name: Prepare Blazor WASM for GitHub Pages
72-
uses: na1307/blazor-github-pages@v2
86+
uses: na1307/blazor-github-pages@3
7387
id: prepare
7488
with:
75-
project-path: BluehillHomePage/BluehillHomePage.csproj
76-
main-repo: true
89+
project-path: MyBlazorApp/MyBlazorApp.csproj
7790
- name: Setup Pages
7891
uses: actions/configure-pages@v5
7992
- name: Upload artifact
@@ -93,3 +106,40 @@ jobs:
93106
id: deployment
94107
uses: actions/deploy-pages@v4
95108
```
109+
110+
## Inputs and Outputs
111+
112+
This action has two inputs and one output.
113+
114+
### Inputs
115+
116+
`project-path`: Path of project (.csproj). Required, no default value. For example: `MyBlazorApp/MyBlazorApp.csproj`.
117+
118+
`publish-path`: Path to output in the Publish step. Most of the time, you can leave this as the default `_out`. However,
119+
you can specify a custom path if needed for your project structure or workflow requirements.
120+
121+
> **Note:** Inputs `main-repo` and `fix-404` have been **deprecated** as of version v3.
122+
> This action now:
123+
> - Automatically detects if the repository is the default Pages repository (username.github.io).
124+
> - Modifies `404.html` if it exists.
125+
126+
### Outputs
127+
128+
`wwwroot-path`: The resulting `wwwroot` path. It must be passed to `path` in the `upload-pages-artifact` action.
129+
130+
## Troubleshooting
131+
132+
### Common Issues
133+
134+
1. **`wwwroot` Path Not Found**
135+
- Ensure the Blazor project builds and publishes successfully.
136+
- Verify that the `publish-path` input matches the expected output directory.
137+
138+
2. **Deployment Fails**
139+
- Ensure that your repository’s Pages Source is set to **GitHub Actions**.
140+
- Check the logs in the **Deploy to GitHub Pages** step for detailed error messages.
141+
142+
3. **Routing Issues**
143+
- Confirm that `gh-pages.js` is included in `index.html` as shown in [Step 1](#1-set-the-project).
144+
145+
For additional support, file an issue in the [GitHub repository](https://github.com/na1307/blazor-github-pages).

image1.png

59.3 KB
Loading

0 commit comments

Comments
 (0)