Skip to content

Commit

Permalink
Merge branch 'feature/Front-End-To-GitHub-Pages' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
aa89227 committed Aug 15, 2023
2 parents 4324289 + ea6720f commit 8dbc911
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/Front-End.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Deploy to GitHub Pages

# 設定值
env:
GitHub_Pages_PathName: "Monopoly" # 網址目錄名稱 (EX: https://app.github.io/Monopoly/ 的Monopoly部分
FRONTEND_PUBLISH_Name: "Client" # 前端專案目錄名稱(必須同專案名稱)

on:
push:
branches: [master, main, feature/Front-End-To-GitHub-Pages] #偵測分支
paths:
- "Client/**" #偵測目錄

jobs:
deploy-to-github-pages:
# 使用ubuntu
runs-on: ubuntu-latest

defaults:
run:
working-directory: ${{ env.FRONTEND_PUBLISH_Name }} # 全局設定工作目錄

steps:
# 使用checkout actions
- uses: actions/checkout@v3

# 安裝.NET Core SDK
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

# # 執行單元測試專案
# - name: Run Unit Test
# run: dotnet test --no-build

# 發佈程式到Release資料夾
- name: Publish .NET Core Project
run: dotnet publish -c Release -o release --nologo

# 修改index.html的base href -- 從"/"改為"/TodoBlazor/"
- name: Change base-tag in index.html from / to TodoBlazor
run: sed -i 's/<base href="\/" \/>/<base href="\/${{ env.GitHub_Pages_PathName }}\/" \/>/g' release/wwwroot/index.html

# 複製index.html內容到404.html
- name: copy index.html to 404.html
run: cp release/wwwroot/index.html release/wwwroot/404.html

# 加入一個.nojekyll檔案
- name: Add .nojekyll file
run: touch release/wwwroot/.nojekyll

# 將release/wwwroot的程式碼,push到gh-pages分支
- name: Commit wwwroot to GitHub Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: ${{ env.FRONTEND_PUBLISH_Name }}/release/wwwroot

0 comments on commit 8dbc911

Please sign in to comment.