I'm testing out deploying a Hexo site on GitLab Pages. I'm currently using a theme that someone has posted to GitHub, and thus have a Git submodule in the themes folder of my Hexo project such that the top-level .gitmodules file looks like:
[submodule "themes/Hacker"]
path = themes/Hacker
url = https://github.com/CodeDaraW/Hacker.git
I'm using the Hexo doc's recommended YAML file (updated for current Node) for CI settings, and the CI job seems to go smoothly except that it randomly decides to skip Git submodules setup:
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
This prevents the site from properly generating the HTML/CSS files because no theme is present:
$ 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
How do I ensure that GitLab actually loads the Git submodule properly so that my theme loads?
From gitlab documenation Using Git submodules with GitLab CI/CD:
Use Git submodules in CI/CD jobs
To make submodules work correctly in CI/CD jobs:
Make sure you use relative URLs for submodules located in the same GitLab server.
You can set the GIT_SUBMODULE_STRATEGY variable to either normal or recursive to tell the runner to fetch your submodules before the job:
variables: GIT_SUBMODULE_STRATEGY: recursive
Also see https://docs.gitlab.com/ee/ci/runners/configure_runners.html#git-submodule-strategy .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With