Automatically fix url and baseurl in GitLab CI

parent b2024ed9
Pipeline #17 passed with stage
in 1 minute and 13 seconds
#!/bin/bash
if [[ "$CI_JOB_ID" == "" ]]; then
echo "Not running in GitLab CI" 1>&2
exit
fi
# Remove everything before the domain from CI_PAGES_URL
ci_baseurl="${CI_PAGES_URL##*$CI_PAGES_DOMAIN}"
# Opposite of above
ci_url="${CI_PAGES_URL%$ci_baseurl*}"
# Remove trailing / from baseurl
if [[ "$ci_baseurl" == */ ]]; then
ci_baseurl="${ci_baseurl%/*}"
fi
sed -i 's|^baseurl:.*$|baseurl: "'"$ci_baseurl"'"|' _config.yml
sed -i 's|^url:.*$|url: "'"$ci_url"'"|' _config.yml
...@@ -11,6 +11,7 @@ before_script: ...@@ -11,6 +11,7 @@ before_script:
pages: pages:
stage: deploy stage: deploy
script: script:
- ./.ci_fix_baseurl.sh
- jekyll build -d public - jekyll build -d public
artifacts: artifacts:
paths: paths:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment