So, I’m using Gitlab-CE for something non-prod, and I want to test MRs before I merge them. Assuming I publish to hxxps://gitlab.pages.example.org/mypage, is there any way to publish to a commitish path (e.g. hxxps://gitlab.pages.example.org/mypage/a1b2c3d4/) when I test something?
My existing .gitlab-ci.yml looks like this:
image: ruby:latest
variables:
JEKYLL_ENV: production
LC_ALL: C.UTF-8
cache:
paths:
- vendor/
workflow:
rules:
- if: '$CI_COMMIT_BRANCH'
before_script:
- 'sed -i -e "s~url: .*\$~url: \"http://${CI_PAGES_URL}/\"~" _config.yml'
- 'sed -i -e "s~git_repo: .*\$~git_repo: \"${CI_PROJECT_URL}\"~" _config.yml'
- gem install bundler
- bundle config set --local path 'vendor'
- bundle install
pages:
stage: deploy
script:
- 'sed -i -e "s~baseurl: .*\$~baseurl: \"/$CI_PROJECT_NAME\"~" _config.yml'
- bundle exec jekyll build -d public
artifacts:
paths:
- public
only:
- main
I’m clearly struggling to find the right terminology search for a way to do this… One thing I thought of doing was, in test, to use the “triggered” commit and build that into test/
and then check out main
, and build that into public/
, and then copy test/
into public/${commitish}
, but then that would be overwritten the first time I get two MRs come in close together, unless I then can somehow manually re-run the CI job before assessing whether the merge should go ahead… And if I can do that, would I be better off preventing the CI job from running unless it’s manually triggered, somehow?