我正在测试如何在GitLab页面上部署一个十六进制站点。我目前使用的是有人发布到GitHub上的一个主题,因此在我的Hexo项目的themes
文件夹中有一个Git子模块,使得顶级.gitmodules
文件看起来像这样:
[submodule "themes/Hacker"]
path = themes/Hacker
url = https://github.com/CodeDaraW/Hacker.git
我使用Hexo文档推荐的YAML文件(针对当前节点更新)进行CI设置,CI工作似乎进展顺利,只是它随机决定跳过Git子模块设置:
Getting source from Git repository 00:01
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/jjeffrey/jjeffrey.gitlab.io/.git/
Created fresh repository.
Checking out 76f8757a as master...
Skipping Git submodules setup
Restoring cache 00:01
Checking cache for default...
FATAL: file does not exist
这会阻止站点正确生成HTML/CSS文件,因为不存在主题:
$ hexo generate
INFO Validating config
INFO Start processing
INFO Files loaded in 100 ms
WARN No layout: 1970/01/01/hello-world/index.html
WARN No layout: 1970/01/01/test_new/index.html
WARN No layout: archives/index.html
WARN No layout: archives/1970/index.html
WARN No layout: archives/1970/01/index.html
WARN No layout: index.html
INFO Generated: archives/index.html
INFO Generated: archives/1970/index.html
INFO Generated: archives/1970/01/index.html
INFO Generated: index.html
INFO Generated: 1970/01/01/hello-world/index.html
INFO Generated: 1970/01/01/test_new/index.html
INFO 6 files generated in 13 ms
如何确保GitLab正确加载Git子模块,以便加载我的主题?
发布于 2021-06-20 23:57:47
来自gitlab documenation Using Git submodules with GitLab CI/CD
在CI/CD作业中使用Git子模块
要使子模块在CI/CD作业中正常工作,请执行以下操作:
变量: GIT_SUBMODULE_STRATEGY: recursive
另请参阅https://docs.gitlab.com/ee/ci/runners/configure_runners.html#git-submodule-strategy。
发布于 2021-06-20 20:53:58
我通过向.gitlab-ci.yml
添加一行代码来更新Git子模块,然后再继续脚本的其余部分,从而解决了这个问题。
image: node:14.17.1
cache:
paths:
- node_modules/
before_script:
- git submodule update --init
- npm install hexo-cli -g
- npm install
pages:
script:
- hexo generate
artifacts:
paths:
- public
only:
- master
https://stackoverflow.com/questions/68052124
复制相似问题