增加前端部屬腳本 #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to GitHub Pages | |
# 設定值 | |
env: | |
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="\/BlazorApp\/" \/>/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/github-pages-deploy-action@v4.3.3 | |
with: | |
branch: gh-pages | |
folder: ${{ env.FRONTEND_PUBLISH_Name }}/release/wwwroot |