diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2021-03-01 15:40:19 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2021-03-19 13:05:37 +0300 |
commit | affb046528285049509a38a23af0dbcc6e44b355 (patch) | |
tree | ccf92df1898c77c1059209c22ed0dbd9604e5edc | |
parent | b912f3542568ec70a0e762cdb9d15de2349ab3b7 (diff) |
Make readme symlinks work on stable branches
https://gitlab.com/gitlab-org/gitlab-docs/-/merge_requests/1499
didn't account for the stable branches, and we now have
redirect loops. This commit fixes that by using the
'symlink_readmes' raketask for the branches that have it
and the old method for old branches.
-rw-r--r-- | dock | 20 | ||||
-rw-r--r-- | dockerfiles/Dockerfile.builder.onbuild | 4 | ||||
-rwxr-xr-x | scripts/check_symlinks.sh | 7 | ||||
-rwxr-xr-x | scripts/normalize-links.sh | 10 |
4 files changed, 39 insertions, 2 deletions
@@ -0,0 +1,20 @@ +# Get Nanoc bootstrap +FROM registry.gitlab.com/gitlab-org/gitlab-docs:bootstrap + +# Make the variables of the archive Dockerfiles accessible to this build-stage +ONBUILD ARG VER +ONBUILD ARG NANOC_ENV +ONBUILD ARG CI_COMMIT_REF_NAME +ONBUILD ARG BRANCH_EE +ONBUILD ARG BRANCH_OMNIBUS +ONBUILD ARG BRANCH_RUNNER +ONBUILD ARG BRANCH_CHARTS + +# Build the docs from this branch +ONBUILD COPY . /source/ +ONBUILD RUN NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install --jobs 4 +ONBUILD RUN yarn install +## For 13.9 and later, there's a raketask that is run instead of the +## manual READMEs symlinking that is defined in scripts/normalize-links.sh. +## If the raketask is present, run it. +ONBUILD RUN [ -f /scripts/check_symlinks.sh ] && /scripts/check_symlinks.sh || "/scripts/normalize-links.sh not found" diff --git a/dockerfiles/Dockerfile.builder.onbuild b/dockerfiles/Dockerfile.builder.onbuild index 48491a23..d030abed 100644 --- a/dockerfiles/Dockerfile.builder.onbuild +++ b/dockerfiles/Dockerfile.builder.onbuild @@ -17,6 +17,10 @@ ONBUILD RUN yarn install ONBUILD RUN bundle exec rake setup_git default ONBUILD RUN yarn install ONBUILD RUN bundle exec nanoc compile -VV +## For 13.9 and later, there's a raketask that is run instead of the +## manual READMEs symlinking that is defined in scripts/normalize-links.sh. +## If the raketask is present, run it. +ONBUILD RUN [ -f /scripts/check_symlinks.sh ] && /scripts/check_symlinks.sh || "/scripts/check_symlinks.sh not found" # Move generated HTML to /site ONBUILD RUN mkdir /site diff --git a/scripts/check_symlinks.sh b/scripts/check_symlinks.sh new file mode 100755 index 00000000..2f76892b --- /dev/null +++ b/scripts/check_symlinks.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +bundle exec rake -T | grep symlink_readmes +if [ $? -eq 0 ] +then + bundle exec rake symlink_readmes +fi diff --git a/scripts/normalize-links.sh b/scripts/normalize-links.sh index 502b6d2d..0e35e022 100755 --- a/scripts/normalize-links.sh +++ b/scripts/normalize-links.sh @@ -85,9 +85,15 @@ find ${TARGET}/$VER -type f -name 'sitemap.xml' -print0 | xargs -0 sed -i 's#doc ## In order to have clean URLs, we symlink README.html to index.html. ## That way, visiting https://docs.gitlab.com/ee/ would be the same as ## visiting https://docs.gitlab.com/ee/{README.html,index.html} +## For 13.9 and later, there's a raketask that is run instead of the +## command below. If the raketask is present, skip the command. ## -echo "Symlink all README.html to index.html" -for i in `find ${TARGET}/${VER} -name README.html`; do ln -sf README.html $(dirname $i)/index.html; done +bundle exec rake -T | grep symlink_readmes +if [ $? -eq 1 ] +then + echo "Symlink all README.html to index.html" + for i in `find ${TARGET}/${VER} -name README.html`; do ln -sf README.html $(dirname $i)/index.html; done +fi ## ## Don't deploy the CE docs since they are identical to the EE ones. |