首先說(shuō)明gitpages放的靜態(tài)頁(yè)面,路由刷新會(huì)報(bào)404
項(xiàng)目準(zhǔn)備工作:
在vue.config.js里邊的publicPath改為 “/項(xiàng)目名/”

項(xiàng)目準(zhǔn)備.png
1.點(diǎn)擊個(gè)人頭像,選擇Settings

第一步.png
2.選擇Developer settings

第二步.png
3.進(jìn)入之后左側(cè)選擇personal access tokens

第三步.png
4.第四步 生成新的令牌,填寫好令牌名,選擇權(quán)限之后,即可看到生成的token

第四步.png
5.拿到token之后,一定要復(fù)制,然后返回git倉(cāng)庫(kù),選擇setting

第五步.png
6.選擇Sercrets

第六步.png
7.選擇New sercrets,將我們剛復(fù)制的token起個(gè)名字復(fù)制到這里保存

第七步.png
8.選擇actions

第八步.png
9.git內(nèi)置很多yml模板,不需要選擇,點(diǎn)擊

第九步.png
10.給yml文件寫名字,并編寫yml文件,此處僅做了vue的

第十步.png
name: buildAndDeploy
on:
push
jobs:
build-and-deploy:
runs-on: ubuntu-latest # 我們選擇使用最新的ubuntu系統(tǒng)
steps:
- name: checkout
uses: actions/checkout@master # 將代碼拷貝到虛機(jī)中
- name: buildAndDeploy
uses: JamesIves/github-pages-deploy-action@master
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # 使用剛新建的secret
BRANCH: gh-pages # 存放產(chǎn)物的分支名稱
FOLDER: dist # 存放build后產(chǎn)物的目錄
BUILD_SCRIPT: npm install && npm run build # 執(zhí)行的命令
11.點(diǎn)擊start commit ->commit new file

11.png
12.此時(shí)回到actions即可看到我們剛的yml文件正在執(zhí)行
13.點(diǎn)擊settings->options 下拉找到github page,選擇yml文件內(nèi)些的分支名
選中之后即可看到 Your site is published at ....

13.png
示例地址:https://wangxunahe1996.github.io/vue-openlayers/
git地址:https://github.com/wangxunahe1996/vue-openlayers