From 025f09a50ca25318be81813987d0294ed0311ed3 Mon Sep 17 00:00:00 2001
From: Miguel Angel Reina Ortega <miguelangel.reinaortega@etsi.org>
Date: Mon, 25 Sep 2023 15:06:02 +0200
Subject: [PATCH] Add GitLab pages to host published spec versions

---
 .gitlab-ci.yml | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d8ce84a..144bc46 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -73,3 +73,26 @@ Publish spec:
     name: "${CI_PROJECT_NAME}_${CI_COMMIT_TAG}"
     paths:
       - "${CI_PROJECT_NAME}_${CI_COMMIT_TAG}.docx"
+
+pages:
+  stage: publication
+  only:
+    - tags
+  dependencies:
+    - Publish spec
+  script:
+    # Get the previous GitLab Pages content
+    - set +e
+    - curl --fail "$CI_PAGES_URL/content.zip" -o "content.zip"
+    - if [ -e "content.zip" ]; then unzip "content.zip"; rm "content.zip"; fi
+    - set -e
+    # Add/update content
+    - mkdir -p "public/$CI_COMMIT_REF_NAME"
+    - cp -r -f "${CI_PROJECT_NAME}_${CI_COMMIT_TAG}.docx" public/$CI_COMMIT_REF_NAME
+    - echo "public/$CI_COMMIT_REF_NAME" >> "public/index.html"
+    # Zip the content and publish the zip again
+    - zip -r "content.zip" "public"
+    - mv "content.zip" "public/"
+  artifacts:
+    paths:
+      - public
\ No newline at end of file
-- 
GitLab