Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto deploy mkdocs with versionning using mike on gitlab pages

I'm willing to deploy a new version of the doc each time I commit a tag on gitlab. I'm using mike for the mkdocs versionning.

I want the versionning to be handle directly on the remote repository not locally.

Locally, I perfom my changes but each time I send a new tag, I would like the get a new added version of the doc on my gitlab page

like image 496
Joy Jedidja Ndjama Avatar asked Oct 18 '25 02:10

Joy Jedidja Ndjama


1 Answers

Finally, I found a solution here.

Here is my adaptation:

pages:
  stage: deploy
  variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
    PAGES_BRANCH: gl-pages
    HTTPS_REMOTE: https://gitlab-ci-token:${ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git
  before_script:
    - pip install mkdocs mike
    - git config user.name $GITLAB_USER_NAME
    - git config user.email $GITLAB_USER_EMAIL
    - git fetch origin $PAGES_BRANCH && git checkout -b $PAGES_BRANCH origin/$PAGES_BRANCH || echo "Pages branch not deployed yet."
    - git checkout $CI_COMMIT_SHA
  script:
   - mike deploy --rebase --prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH -u $CI_COMMIT_TAG latest
   - mike set-default --rebase --prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH latest
   - git checkout $PAGES_BRANCH -- public/
  artifacts:
    paths:
     - public/
  only:
    - tags
like image 178
Joy Jedidja Ndjama Avatar answered Oct 21 '25 05:10

Joy Jedidja Ndjama



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!