2
2
3
3
This action allows you to deploy your Blazor WASM app to GitHub Pages.
4
4
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
+
5
16
## What this does
6
17
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.
9
19
10
20
## How to use
11
21
12
- First, set Repository Settings - Pages - Source to GitHub Actions.
22
+ ### 1. Set the Project
13
23
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.
15
27
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
+ ```
17
35
18
- ` project-path ` : Path of project (.csproj). Default is
19
- ` (repo name)/(repo name).csproj ` .
36
+ ### 2. Set the repository settings
20
37
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** .
23
39
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:
26
41
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 )
29
43
30
- ### Outputs
44
+ ### 3. Add workflow file
31
45
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 .
34
48
35
- ## Example Workflow
49
+ > ** Replace ` MyBlazorApp/MyBlazorApp.csproj ` with your actual ` .csproj ` path. **
36
50
37
51
``` yml
38
- name : Deploy
52
+ name : Deploy GitHub Pages
39
53
40
54
on :
41
55
# Runs on pushes targeting the default branch
42
56
push :
43
- branches : ["main"]
57
+ branches : [ "main" ]
44
58
45
59
# Allows you to run this workflow manually from the Actions tab
46
60
workflow_dispatch :
@@ -67,13 +81,12 @@ jobs:
67
81
- name : Setup .NET
68
82
uses : actions/setup-dotnet@v4
69
83
with :
70
- dotnet-version : 8 .0.x
84
+ dotnet-version : 9 .0.x
71
85
- name : Prepare Blazor WASM for GitHub Pages
72
- uses : na1307/blazor-github-pages@v2
86
+ uses : na1307/blazor-github-pages@3
73
87
id : prepare
74
88
with :
75
- project-path : BluehillHomePage/BluehillHomePage.csproj
76
- main-repo : true
89
+ project-path : MyBlazorApp/MyBlazorApp.csproj
77
90
- name : Setup Pages
78
91
uses : actions/configure-pages@v5
79
92
- name : Upload artifact
@@ -93,3 +106,40 @@ jobs:
93
106
id : deployment
94
107
uses : actions/deploy-pages@v4
95
108
` ` `
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).
0 commit comments