From d44e8e3d941536d4727dba396be13ad3d9f253c0 Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
Date: Fri, 26 Mar 2021 19:00:11 +0100
Subject: [PATCH] gitlab-ci.yml: trigger docs pipeline after building-docs

When documentation changes, trigger the docs pipeline to update the
aggregated documentation view.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
---
 .ostc-ci/gitlab-ci.yml | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/.ostc-ci/gitlab-ci.yml b/.ostc-ci/gitlab-ci.yml
index d9bac9f6..0006509b 100644
--- a/.ostc-ci/gitlab-ci.yml
+++ b/.ostc-ci/gitlab-ci.yml
@@ -18,6 +18,7 @@ stages:
   - compliance
   - build
   - test
+  - deploy
 
 include:
  - project: 'OSTC/infrastructure/pipelines'
@@ -58,6 +59,29 @@ build-docs:
         - docs/**/*
         # Run this job in case the pipeline changes.
         - .ostc-ci/*.yml
+    # Or when things land.
+    - if: '$CI_BRANCH_NAME == "$CI_DEFAULT_BRANCH"'
+      changes:
+        # React to changes to the docs directory.
+        - docs/**/*
+        # Run this job in case the pipeline changes.
+        - .ostc-ci/*.yml
+
+# When the build-docs pipeline is triggered by documentation change and it
+# succeeds, then trigger the pipeline in the OSTC/OHOS/docs repository, to
+# update the published documentation.
+update-docs:
+  needs: [build-docs] # depend on build-docs to avoid publishing broken things.
+  stage: deploy
+  trigger: OSTC/OHOS/docs
+  rules:
+    # Update the documentation when things land in the default branch.
+    - if: '$CI_BRANCH_NAME == "$CI_DEFAULT_BRANCH"'
+      changes:
+        # React to changes to the docs directory.
+        - docs/**/*
+        # Run this job in case the pipeline changes.
+        - .ostc-ci/*.yml
 
 # Customize the generic .build job, included from build-generic.yaml above,
 # with settings for testing updates to the meta-ohos git repository.
-- 
GitLab