-
Notifications
You must be signed in to change notification settings - Fork 14
42 lines (31 loc) · 1.3 KB
/
publish-to-gh-pages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Build and publish to gh pages
on:
push:
branches: [ "*" ]
env:
ASPNETCORE_ENVIRONMENT: Production
WEBAPP_PATH: ./
WEBAPP_CSPROJ: BlazorStaticMinimalBlog.csproj
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Remove launchSettings.json (to not override ASPNETCORE_ENVIRONMENT)
run: rm ${{ env.WEBAPP_PATH }}Properties/launchSettings.json
- name: Change <base href="" /> in App.razor to match GitHub repo name
run: |
REPO_NAME=$(echo "${{ github.repository }}" | awk -F '/' '{print $NF}')
if [[ "$REPO_NAME" != *.github.io ]]; then
sed -i 's|<base href="/"*/>|<base href="/'$REPO_NAME'/" />|g' ${{ env.WEBAPP_PATH }}/Components/App.razor
fi
- name: Run webapp and generate static files
run: |
dotnet run --project ${{ env.WEBAPP_PATH }}${{env.WEBAPP_CSPROJ}} --configuration Release
- run: touch ${{ env.WEBAPP_PATH }}/output/.nojekyll #folder starting with _ are handled as jekyll. This file will prevent that.
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ${{ env.WEBAPP_PATH }}output