diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2018-03-23 20:13:37 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2018-03-23 20:13:37 +0300 |
commit | 715c566932b3414857982562b9af106eb05f7250 (patch) | |
tree | ed1a61bc2944286ef06dcd0252698b005db07742 | |
parent | 9f897d17acfc978234767aaa595dee0ca05004e5 (diff) | |
parent | 17b3ff21a79a3e52c6ac11e9d4d1bbd7466a9bbd (diff) |
Merge branch 'versions_round_two' into 'master'
Versions round two
See merge request gitlab-com/gitlab-docs!220
-rw-r--r-- | .gitlab-ci.yml | 6 | ||||
-rw-r--r-- | content/robots.txt.erb | 6 | ||||
-rw-r--r-- | dockerfiles/Dockerfile.builder.onbuild | 2 | ||||
-rw-r--r-- | dockerfiles/README.md | 31 | ||||
-rw-r--r-- | layouts/default.html | 3 | ||||
-rw-r--r-- | layouts/disqus.html | 3 | ||||
-rw-r--r-- | layouts/footer.html | 3 | ||||
-rwxr-xr-x | scripts/normalize-links.sh | 2 |
8 files changed, 48 insertions, 8 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f81246c7..24ffbf86 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -268,7 +268,7 @@ image:docs-stable: NANOC_ENV: 'production' IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME script: - - docker build -t $IMAGE_NAME . + - docker build --build-arg NANOC_ENV=${NANOC_ENV} --build-arg CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME} -t $IMAGE_NAME . - docker push $IMAGE_NAME # Only branches with versions like 10.4 only: @@ -291,7 +291,7 @@ image:docs-archives: <<: *except_stable # -# Build master containing all archives +# Build master containing all archives and latest docs # image:docs-latest: stage: docker-stable @@ -300,7 +300,7 @@ image:docs-latest: NANOC_ENV: 'production' IMAGE_NAME: $CI_REGISTRY_IMAGE:latest script: - - docker build -t $IMAGE_NAME . + - docker build --build-arg NANOC_ENV=${NANOC_ENV} --build-arg CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME} -t $IMAGE_NAME . - docker push $IMAGE_NAME only: - master diff --git a/content/robots.txt.erb b/content/robots.txt.erb index db1d0b75..b4a4b64f 100644 --- a/content/robots.txt.erb +++ b/content/robots.txt.erb @@ -2,4 +2,10 @@ is_hidden: true --- +<% if ENV['CI_COMMIT_REF_NAME'] == 'master' %> Sitemap: <%= @items['/sitemap.*'].path %> +<% else %> +# Ban all spiders from the entire site when not on master branch +User-Agent: * +Disallow: / +<% end %> diff --git a/dockerfiles/Dockerfile.builder.onbuild b/dockerfiles/Dockerfile.builder.onbuild index 02606155..ec2a9a6c 100644 --- a/dockerfiles/Dockerfile.builder.onbuild +++ b/dockerfiles/Dockerfile.builder.onbuild @@ -3,6 +3,8 @@ FROM registry.gitlab.com/gitlab-com/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_CE ONBUILD ARG BRANCH_OMNIBUS diff --git a/dockerfiles/README.md b/dockerfiles/README.md index efc5fde2..1c0dbfab 100644 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -1,7 +1,8 @@ -# Dockerfiles used to build the docs site +# How the versioned website is built -This directory contains all needed Dockerfiles to build and deploy the website. -It is heavily inspired by Docker's [publish tools](https://github.com/docker/docker.github.io/tree/publish-tools). +This directory contains all needed Dockerfiles to build and deploy the +versioned website. It is heavily inspired by Docker's +[publish tools](https://github.com/docker/docker.github.io/tree/publish-tools). The following Dockerfiles are used. @@ -59,6 +60,16 @@ branch: FROM registry.gitlab.com/gitlab-com/gitlab-docs:nginx-onbuild ``` +1. Test locally by building the image and running it: + + ``` + docker build -t docs:10.5 . + docker run -it --rm -p 4000:4000 docs:10.5 + ``` + +1. Visit http://localhost:4000/10.5/ and make sure everything works correctly +1. Commit your changes and push (don't create a merge request) + Once you push, the `image:docker-stable` job will create a new Docker image tagged with the branch name. @@ -68,4 +79,16 @@ With every new release on the 22nd, the archives Docker image should be updated. Edit the following files and add the new version: - `content/archives/index.md` -- [`Dockerfile.archives`](/Dockerfile.archives) +- [`Dockerfile.archives`](Dockerfile.archives) + +## Porting new website changes to old versions + +The website will keep changing and being improved. In order to consolidate +those changes to the stable branches, we'd need to merge master into them +from time to time. + +```sh +git branch 10.5 +git fetch origin master +git merge origin/master +``` diff --git a/layouts/default.html b/layouts/default.html index d09455d9..b08da70f 100644 --- a/layouts/default.html +++ b/layouts/default.html @@ -43,9 +43,12 @@ <div class="article-content js-article-content"> <%= yield %> </div> + <% if ENV['NANOC_ENV'] == 'production' && ENV['CI_COMMIT_REF_NAME'] == 'master' %> + <%# Show Edit button only in production and on master branch (hide archives) %> <div class="edit-on"> <%= edit_on_gitlab(@item) %> </div> + <% end %> <% if @item[:last_updated] %> <hr> <p class="last-updated"> diff --git a/layouts/disqus.html b/layouts/disqus.html index 34a0b578..3c6eff15 100644 --- a/layouts/disqus.html +++ b/layouts/disqus.html @@ -1,4 +1,5 @@ -<% if @item[:comments].nil? && ENV['NANOC_ENV'] == 'production' %> +<%# Show comments only in production and on master branch (hide archives) %> +<% if @item[:comments].nil? && ENV['NANOC_ENV'] == 'production' && ENV['CI_COMMIT_REF_NAME'] == 'master' %> <% unless @item.identifier.to_s.split('/')[1] == 'ce' %> <div class="comments"> <p><em>Leave a comment below if you have any feedback on the documentation. For support and other enquiries, see <a href="https://about.gitlab.com/getting-help/" target="_blank">getting help</a>.</em></p> diff --git a/layouts/footer.html b/layouts/footer.html index 8212535d..384a4393 100644 --- a/layouts/footer.html +++ b/layouts/footer.html @@ -2,9 +2,12 @@ <%= render '/footer_links.*' %> <div class='animated text-center source-link'> <a href='https://gitlab.com/gitlab-com/gitlab-docs' target='_blank'>Created</a> with Nanoc, hosted on <a href='https://about.gitlab.com/features/pages/' target='_blank'>GitLab Pages</a> + <% if ENV['NANOC_ENV'] == 'production' && ENV['CI_COMMIT_REF_NAME'] == 'master' %> + <%# Show Edit button only in production and on master branch (hide archives) %> <div class="edit-on"> <i class="fa fa-code-fork" aria-hidden="true"></i> <%= edit_on_gitlab(@item) %> </div> + <% end %> </div> </footer> diff --git a/scripts/normalize-links.sh b/scripts/normalize-links.sh index a6b2a34d..6189d5bf 100755 --- a/scripts/normalize-links.sh +++ b/scripts/normalize-links.sh @@ -27,6 +27,8 @@ find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/runner/#=" find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/omnibus/#="/'"$VER"'/omnibus/#g' find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/assets/#="/'"$VER"'/assets/#g' find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#<a href="/">#<a href="/'"$VER"'/">#g' +find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/opensearch.xml#="/'"$VER"'/opensearch.xml#g' +find ${TARGET} -type f -name 'sitemap.xml' -print0 | xargs -0 sed -i 's#docs.gitlab.com/#docs.gitlab.com/'"$VER"'/#g' # 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 |