From eaf39b14411d28f6324f6fbde99d47dc63892f0e Mon Sep 17 00:00:00 2001
From: Bartek Wrona <wrona@syncad.com>
Date: Mon, 20 May 2024 23:23:32 +0200
Subject: [PATCH] Defined template job base definition:
 `.npm_push_doc_template'

---
 templates/npm_projects.gitlab-ci.yml | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/templates/npm_projects.gitlab-ci.yml b/templates/npm_projects.gitlab-ci.yml
index a34960a..1e77b02 100644
--- a/templates/npm_projects.gitlab-ci.yml
+++ b/templates/npm_projects.gitlab-ci.yml
@@ -140,3 +140,28 @@ variables:
     - if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"'
       when: manual
       allow_failure: true
+
+# Allows to store generated documentation files inside a wiki repo specific to given project. Wiki repo must be explicitly created before using this job.
+# Documentation files coming to protected branches are committed into root directory in the wiki repo. All other changes are pushed into non-stable/<branch-name> subdirectory what allows to render them by wiki.
+.npm_push_doc_template:
+  extends: .npm_based_job_base
+  variables:
+    # Must be overrided by derived job
+    WIKI_PUSH_TOKEN: ""
+
+    # The directory containing sources to be built - it can be overrided by derived job
+    SOURCE_DIR: "${CI_PROJECT_DIR}"
+
+    # Output directory where should be stored `docs' subdirectory containing generated documentation files
+    DIST_DIR: "$CI_PROJECT_DIR/dist"
+
+  script:
+    - /home/emscripten/scripts/npm_push_doc.sh "${SOURCE_DIR}" "${CI_PROJECT_URL}" "${WIKI_PUSH_TOKEN}" "${DIST_DIR}" "${CI_COMMIT_REF_NAME}" "${CI_COMMIT_REF_PROTECTED}"
+
+  artifacts:
+    reports:
+      dotenv:
+        - "gen_doc.env"  # contains URL to generated documentation pointed by `GEN_DOC_URL` variable
+
+    when: always
+    expire_in: 1 week
-- 
GitLab