From f3273bc203ea9da54314a043b36430d349e146cb Mon Sep 17 00:00:00 2001
From: Jason Kridner <jkridner@beagleboard.org>
Date: Sun, 3 Jul 2022 15:24:04 -0400
Subject: [PATCH] Move content under latest

---
 .gitlab-ci.yml | 28 +++++++++++++++++++++-------
 redirect.html  |  9 +++++++++
 2 files changed, 30 insertions(+), 7 deletions(-)
 create mode 100644 redirect.html

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 42ddb4ac..c4ac5e1e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,7 +1,8 @@
 image: python:3.9-alpine
 
 stages:
-  - deploy
+  - deploy-main
+  - deploy-branch
 
 before_script:
   - apk update
@@ -13,15 +14,28 @@ before_script:
   - apk add texlive-full
   - apk add make
 
-pages:
-  stage: deploy
+pages_main:
+  stage: deploy-main
   script:
-  - sphinx-build -b html . public
-  - sphinx-build -M latexpdf . public
-  - mv public/latex/bbdocs.pdf public
+  - sphinx-build -b html . public/latest
+  - sphinx-build -M latexpdf . public/latest
+  - mv public/latex/bbdocs.pdf public/latest
+  - cp redirect.html public/index.html
   artifacts:
     paths:
     - public
   rules:
-    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
+    - if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH
+
+pages_branch:
+  stage: deploy-branch
+  script:
+  - sphinx-build -b html . public/$CI_COMMIT_REF_NAME
+  - sphinx-build -M latexpdf . public/$CI_COMMIT_REF_NAME
+  - mv public/latex/bbdocs.pdf public/$CI_COMMIT_REF_NAME
+  artifacts:
+    paths:
+    - public
+  rules:
+    - if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH
 
diff --git a/redirect.html b/redirect.html
new file mode 100644
index 00000000..7964945a
--- /dev/null
+++ b/redirect.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta http-equiv="refresh" content="0; url='latest/'" />
+  </head>
+  <body>
+    <p>Please follow <a href="latest/">this link</a>.</p>
+  </body>
+</html>
-- 
GitLab