我添加了一個主頁,將屬性預部署和部署到我的 package.json 檔案中,將我的應用程式鏈接到我的 github 并運行 npm run deploy。終端指示成功,然后當我轉到我的 Gitpages URL 時,我得到以下資訊:https ://joe-dp.github.io/mh-app/
有誰知道為什么鏈接會將我重定向到 React 資訊頁面?
uj5u.com熱心網友回復:
- 在 Repo → Settings → Pages → Sources 下,選擇
gh-pages分支 - 將您構建的應用程式(例如
dist)放在要提供的 gh-pages 分支的根目錄中
您可能希望自動執行此操作,這可以通過GitHub Actions輕松完成。
以下示例使用JamesIves/github-pages-deploy-action來構建部署您的應用程式,每次在您的主分支上進行更改。
只需在主分支中創建一個檔案.github/workflows/deploy-gh-pages.yml,然后使用以下內容填充它:
name: Build and Deploy to GH Pages
on:
push:
workflow_dispatch:
permissions:
contents: write
jobs:
build-and-deploy:
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install and Build
run: |
yarn
yarn build
- name: Deploy
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: dist
提交您的檔案,該操作將自動運行,幾分鐘后您的應用程式將在 GH Pages 上運行??
如果你想看一個真實的例子,我正在這個專案中做類似的事情。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/485409.html
