在本教程中,我們將會使用 GitLab CI 將 Hexo 博客部署到 GitLab Pages 上。
image: node:10-alpine # use nodejs v10 LTS
cache:
paths:
- node_modules/
?
before_script:
- npm install hexo-cli -g
- npm install
?
pages:
script:
- hexo generate
artifacts:
paths:
- public
only:
- master
在 GitLab.com 上,GitLab CI 是默認(rèn)啟用的。如果你使用的是自托管的 GitLab,你可能需要在 Settings -> CI / CD -> Shared Runners 啟用 GitLab CI。
如果你更希望你的站點(diǎn)部署在 <你的 GitLab 用戶名>.gitlab.io 的子目錄中,你的 repository 需要直接命名為子目錄的名字,這樣你的站點(diǎn)可以通過 https://<你的 GitLab 用戶名>.gitlab.io/<repository 的名字> 訪問。你需要檢查你的 Hexo 配置文件,將 url 的值修改為 https://<你的 GitLab 用戶名>.gitlab.io/<repository 的名字>、將 root 的值修改為 /<repository 的名字>/
更多建議: