From 0ca76a42aa37df66c4c516b80244653ec1fead53 Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
Date: Tue, 27 Sep 2022 11:59:03 +0000
Subject: [PATCH] ci: allow forks to have different names

When the fork of the "docs" repository is called something else, we need to
refer to it by the real name to successfully perform the replacement for merge
request pipelines.

Use some bash and CI_MERGE_REQUEST_SOURCE_PROJECT_PATH to find the bare name of
the project. This works because the variable is re-interpolated by bash during
job execution.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
---
 .gitlab-ci.yml | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8953186..b8fd10e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -217,7 +217,9 @@ build-docs:
     # thing we can do right now.
     - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
       variables:
-        CI_ONIRO_REPO_WORKSPACE_LOCAL_MANIFEST: >
+        CI_ONIRO_REPO_WORKSPACE_LOCAL_MANIFEST_INTERPRETER: eval
+        CI_ONIRO_REPO_WORKSPACE_LOCAL_MANIFEST: |
+          cat <<__EOM__
           <?xml version="1.0" encoding="UTF-8"?>
           <manifest>
             <!-- remove original docs project entry -->
@@ -225,8 +227,9 @@ build-docs:
             <!-- add remote representing the project -->
             <remote name="oniro-override" fetch="${CI_MERGE_REQUEST_SOURCE_PROJECT_URL}/../" />
             <!-- add docs at the exact version are testing -->
-            <project name="${CI_PROJECT_NAME}" path="docs" remote="oniro-override" revision="${CI_COMMIT_SHA}" />
+            <project name="$(basename "$CI_MERGE_REQUEST_SOURCE_PROJECT_PATH")" path="docs" remote="oniro-override" revision="${CI_COMMIT_SHA}" />
           </manifest>
+          __EOM__
     # Or when things land.
     - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
 
-- 
GitLab