Hi all,
after posting a problem here about the source links on Gitlab pages (link), i thought maybe I can share my current setup for nbdev on Gitlab:
Note:
- There is also this post from @rjohnson with a blog post where he describes his setup for Gitlab
- And there is already an issue Support GitLab · Issue #945 · fastai/nbdev · GitHub
Steps
I created a new empty repo, cloned it and set up a venv with pipenv. Then I installed nbdev and all other necessary packages.
After that I ran nbdev_new
(with some warning messages because the default github stuff is not available)
Then I changed settings.ini
and _quarto.yml
for the use with gitlab
Changes made in settings.ini
- set
doc_path = public
- set
branch = main
instead of master - change
doc_host
to your gitlab pages url, e.g.https://{userid}.github.io/{reponame}
- change
git_url
to your gitlab repo url, e.g.https://gitlab.com/{userid}/{reponame}
Changes in _quarto.yml
repo-branch: main
-
site-url
same as above e.g.https://{userid}.gitlab.io/{reponame}
-
repo-url
ditohttps://gitlab.com/{userid}/{reponame}
Note: I just blindly changed every line containing “github”, I really don’t know which of these is relevant. But it works
And to use Gitlab pages you need to adapt the CI-pipeline, here is my (very simple) gitlab-ci.yml
. I am using pipenv here, so you may have to remove/adapt the pipenv related statements.
# The Docker image that will be used to build your app
image: python:3.8-bullseye
# Functions that should be executed before the build script is run
before_script:
- apt install wget
- wget "https://github.com/quarto-dev/quarto-cli/releases/download/v1.1.149/quarto-1.1.149-linux-amd64.deb"
- dpkg -i quarto-1.1.149-linux-amd64.deb
- pip3 install pipenv
- pipenv install --dev
pages:
script:
- pipenv run nbdev_install
- pipenv run nbdev_docs
artifacts:
paths:
# The folder that contains the files to be exposed at the Page URL
- public
rules:
# This ensures that only pushes to the default branch will trigger
# a pages deploy
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
The nbdev command nbdev_publish
doesn’t work here, you can simply push your changes and the docs will be build by the CI-pipeline.
So, I hope this helps maybe one or the other