From dff0489af9baa93275d388f762a5f18386d81f84 Mon Sep 17 00:00:00 2001 From: Sarah German Date: Tue, 6 May 2025 09:57:22 -0500 Subject: [PATCH] Run Hugo build test on the correct Docs branch We need to target the appropriate branch of the Docs site in the event of an MR targeting a stable release branch. --- .gitlab/ci/checks.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/checks.yml b/.gitlab/ci/checks.yml index e61e5429e5..e62afabfbe 100644 --- a/.gitlab/ci/checks.yml +++ b/.gitlab/ci/checks.yml @@ -99,8 +99,24 @@ check_docs_links: docs-test hugo: image: registry.gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/docs-gitlab-com-builder:hugo-0.145.0 stage: prepare + variables: + DOCS_BRANCH: "main" before_script: - - git clone --depth 1 https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com.git + # Check if this is targeting a stable branch + - | + if [[ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ ^([0-9]+)-([0-9]+)-stable ]]; then + # Extract major and minor version from the branch name + CHART_MAJOR=$(echo $CI_MERGE_REQUEST_TARGET_BRANCH_NAME | cut -d '-' -f 1) + CHART_MINOR=$(echo $CI_MERGE_REQUEST_TARGET_BRANCH_NAME | cut -d '-' -f 2) + + # Add 9 to chart major version to get GitLab Docs version + DOCS_MAJOR=$((CHART_MAJOR + 9)) + DOCS_BRANCH="$DOCS_MAJOR.$CHART_MINOR" + + echo "Using docs-gitlab-com branch $DOCS_BRANCH for release branch" + fi + # Clone the Docs website project + - git clone --depth 1 --filter=tree:0 --branch $DOCS_BRANCH https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com.git - cd docs-gitlab-com - make add-latest-icons # Copy the current project's docs to the appropriate location in the docs website -- GitLab