From faab64443ecbb2e53202a07fb2e911400db0e801 Mon Sep 17 00:00:00 2001 From: Emanuele Aina <emanuele.aina@collabora.com> Date: Fri, 11 Sep 2020 12:52:46 +0200 Subject: [PATCH] Fix URLs on forked projects by setting baseURL GitLab Pages only really handles a single branch for each project, so forking is the best way to have the proposed pages be rendered and published by Pages. By setting `baseURL` from CI using `$CI_PAGES_URL` we can ensure that links are set properly instead of always pointing at https://www.apertis.org/ as that's quite confusing during reviews. However, for the main project we don't want to use the default GitLab pages address, but we want to have links using the official https://www.apertis.org/ address: to the main project now sets `$BASEURL` as a CI/CD variable to point at https://www.apertis.org/ while forked projects will use the default based on `$CI_PAGES_URL`. Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com> --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7ed7510c4..cd336c03d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,7 +15,10 @@ test-html: image: registry.gitlab.com/pages/hugo:0.62.2 stage: generate-html script: - - hugo + - DEFAULT_BASEURL=${CI_PAGES_URL##http:} # don't force stuff on plain HTTP when publishing on HTTPS + - BASEURL=${BASEURL:-$DEFAULT_BASEURL} # set BASEURL in the CI variables to override it + - echo "Using base URL '$BASEURL'" + - hugo -b "${BASEURL}" artifacts: paths: - public -- GitLab