From ce6bd825bdc2d45a2a1189c9117b581620b4b55f Mon Sep 17 00:00:00 2001
From: Malte <malte.bauch@stud.h-da.de>
Date: Tue, 13 Apr 2021 12:15:12 +0200
Subject: [PATCH] generated goplantuml to wiki

this CI job makes it possible to fill the page "HOME" of the .wiki with
the UML generated by goplantuml.
---
 build/ci/.uml-autogen-ci.yml | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/build/ci/.uml-autogen-ci.yml b/build/ci/.uml-autogen-ci.yml
index 54feeaabe..2189eac89 100644
--- a/build/ci/.uml-autogen-ci.yml
+++ b/build/ci/.uml-autogen-ci.yml
@@ -1,14 +1,31 @@
 goplantuml:
     image: golang:1.14-alpine
-    stage: .post
+    stage: uml
     when: manual
     variables:
-        FILENAME: "ClassDiagram.puml"
+        FILENAME: "home.md"
+        WIKI_URL: "${CI_SERVER_PROTOCOL}://project_${CI_PROJECT_ID}_bot:${UML_TO_WIKI_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/${CI_PROJECT_PATH}.wiki.git"
 
     script:
     # install git
     - apk update && apk add git
     # install goplantuml
     - go get github.com/jfeliu007/goplantuml/cmd/goplantuml
+    # remove old wiki folder
+    - rm -rf "/tmp/${CI_PROJECT_NAME}.wiki"
+    # clone and move to wiki folder
+    - cd /tmp
+    - git clone "${WIKI_URL}"
+    - cd "${CI_PROJECT_NAME}.wiki"
+
+    - echo '```plantuml' > "$FILENAME"
     # run goplantuml
-    - goplantuml "${CI_PROJECT_DIR}/nucleus" >> "$FILENAME"
+    - goplantuml "${CI_PROJECT_DIR}" >> "$FILENAME"
+    - echo '```' >> "$FILENAME"
+
+    # git commit
+    - git config user.name "$GITLAB_USER_NAME"
+    - git config user.email "$GITLAB_USER_EMAIL"
+    - git add "$FILENAME"
+    - git commit -m "Auto-updated UML diagram"
+    - git push origin "HEAD:master"
-- 
GitLab