From 4e124b58c7bb2fd0c0e4301c333462136201bdbf Mon Sep 17 00:00:00 2001
From: Jason Kridner <jkridner@beagleboard.org>
Date: Wed, 31 Aug 2022 13:21:14 -0400
Subject: [PATCH] attempt to name directories

---
 .gitlab-ci.yml | 49 ++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 38 insertions(+), 11 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 22bd52b3..d4bcc3b1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,22 +1,49 @@
 image: beagle/sphinx-build-env:latest
 
 stages:
-  - deploy
+  - deploy-main
+  - deploy-branch
+  - deploy-tag
 
-cache:
-  paths:
+pages:
+  stage: deploy-main
+  script:
+  - sphinx-build -b html . public/latest/
+  - sphinx-build -M latexpdf . public/latest/
+  - mv public/latex/beagleboard-docs.pdf public/latest/
+  - echo "/ /latest/ 302" > public/latest/_redirects
+  artifacts:
+    paths:
+    - public
+  rules:
+    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+      when: always
+
+pages:
+  stage: deploy-branch
+  script:
+  - sphinx-build -b html . public/$CI_COMMIT_BRANCH/
+  - sphinx-build -M latexpdf . public/$CI_COMMIT_BRANCH/
+  - mv public/latex/beagleboard-docs.pdf public/$CI_COMMIT_BRANCH/
+  artifacts:
+    paths:
     - public
-    - public/0.0.7
+  rules:
+    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+      when: never
+    - if: $CI_COMMIT_BRANCH
+      when: always
 
 pages:
-  stage: deploy
+  stage: deploy-tag
   script:
-  - sphinx-build -b html . public
-  - sphinx-build -M latexpdf . public
-  - mv public/latex/beagleboard-docs.pdf public/
+  - export GIT_BRANCH=$(git branch -a --contains tags/$CI_COMMIT_TAG | grep origin | sed 's/.*origin\///'`
+  - sphinx-build -b html . public/$GIT_BRANCH/
+  - sphinx-build -M latexpdf . public/$GIT_BRANCH/
+  - mv public/latex/beagleboard-docs.pdf public/$GIT_BRANCH/
   artifacts:
     paths:
     - public
-  only:
-    - main
-    - 0.0.7
+  rules:
+    - if: $CI_COMMIT_TAG
+      when: always
-- 
GitLab