diff --git a/generate b/generate
index 88dd480a..172c6a33 100755
--- a/generate
+++ b/generate
@@ -31,19 +31,73 @@ trap "cd '${DEPLOY_DIR}'; rm -rf '${WORK_DIR}'" EXIT
mkdir -p "${WORK_DIR}/public/"
cat << EOF > "${WORK_DIR}/public/index.html"
-
-
+
+
-
-
- PDI: Documentation versions
+
+PDI: Documentation versions
-PDI documentation for:
+PDI documentation for:
EOF
+########################
+## GITHUB
+########################
+DOWNLOAD_URL=$(curl -fsS -H "Authorization: Bearer ${CI_PAGES_TOKEN}" https://api.github.com/repos/${GH_PROJECT_NAME}/actions/artifacts \
+| jq -r '.artifacts
+ | map(select(.workflow_run.head_branch=="main" and .name == "pages"))
+ | sort_by(.created_at)
+ | last
+ | .archive_download_url')
+mkdir -p "${WORK_DIR}/public/main"
+cd "${WORK_DIR}/public/main"
+curl -H "Authorization: Bearer ${CI_PAGES_TOKEN}" -LfsSo artifacts.zip "${DOWNLOAD_URL}"
+unzip -o -d public artifacts.zip
+rm artifacts.zip
+while [ 1 -eq "$(find . -mindepth 1 -maxdepth 1|wc -l)" ]
+do
+ SUBDIR="$(find . -mindepth 1 -maxdepth 1)"
+ find "$SUBDIR" -mindepth 1 -maxdepth 1 -exec mv '{}' . ';'
+ rmdir "$SUBDIR"
+done
+echo "- latest version from GIT
" >> "${WORK_DIR}/public/index.html"
+
+
+
+
+curl -fsS -H "Authorization: Bearer ${CI_PAGES_TOKEN}" https://api.github.com/repos/${GH_PROJECT_NAME}/actions/artifacts \
+| jq -cr '.artifacts
+ | map(select(.name == "pages" and (.workflow_run.head_branch
+ | test("^v[0-9]+\\.[0-9]+$"))))
+ | group_by(.workflow_run.head_branch)
+ | map(sort_by(.created_at))
+ | map(last)
+ | map({url:.archive_download_url,branch:.workflow_run.head_branch})
+ | .[]' \
+| while read TAG_INFO
+do
+ DOWNLOAD_URL="$(jq -r .url <<< "$TAG_INFO")"
+ TAG="$(jq -r .branch <<< "$TAG_INFO" | sed 's/^v//')"
+ mkdir -p "${WORK_DIR}/public/${TAG}"
+ cd "${WORK_DIR}/public/${TAG}"
+ curl -H "Authorization: Bearer ${CI_PAGES_TOKEN}" -LfsSo artifacts.zip "${DOWNLOAD_URL}"
+ unzip -o -d public artifacts.zip
+ rm artifacts.zip
+ while [ 1 -eq "$(find . -mindepth 1 -maxdepth 1|wc -l)" ]
+ do
+ SUBDIR="$(find . -mindepth 1 -maxdepth 1)"
+ find "$SUBDIR" -mindepth 1 -maxdepth 1 -exec mv '{}' . ';'
+ rmdir "$SUBDIR"
+ done
+ echo "- version ${TAG}
" >> "${WORK_DIR}/public/index.html"
+done
+
+
+
+
########################
## GITLAB
########################
@@ -72,7 +126,7 @@ do
then
mv public "${WORK_DIR}/public/${STAG}"
fi
- echo "- version ${STAG}" >> "${WORK_DIR}/public/index.html"
+ echo "
- version ${STAG}
" >> "${WORK_DIR}/public/index.html"
cd "${WORK_DIR}"
rm -rf "${WORK_DIR}/${TAG}"
break
@@ -93,80 +147,10 @@ fi
-########################
-## GITHUB
-########################
-curl -fsS -H "Authorization: Bearer ${CI_PAGES_TOKEN}" https://api.github.com/repos/${GH_PROJECT_NAME}/actions/artifacts \
-| jq -cr '.artifacts
- | map(select(.name == "pages" and (.workflow_run.head_branch
- | test("^v[0-9]+\\.[0-9]+$"))))
- | group_by(.workflow_run.head_branch)
- | map(sort_by(.created_at))
- | map(last)
- | map({url:.archive_download_url,branch:.workflow_run.head_branch})
- | .[]' \
-| while read TAG_INFO
-do
- DOWNLOAD_URL="$(jq -r .url <<< "$TAG_INFO")"
- TAG="$(jq -r .branch <<< "$TAG_INFO" | sed 's/^v//')"
- cd "${WORK_DIR}"
- mkdir -p "public/${TAG}"
- cd "public/${TAG}"
- curl -H "Authorization: Bearer ${CI_PAGES_TOKEN}" -LfsSo artifacts.zip "${DOWNLOAD_URL}"
- unzip -o -d public artifacts.zip
- rm artifacts.zip
- while [ 1 -eq "$(find . -mindepth 1 -maxdepth 1|wc -l)" ]
- do
- SUBDIR="$(find . -mindepth 1 -maxdepth 1)"
- find "$SUBDIR" -mindepth 1 -maxdepth 1 -exec mv '{}' . ';'
- rmdir "$SUBDIR"
- done
- echo "- version ${TAG}" >> "${WORK_DIR}/public/index.html"
-done
-
-
-
-if [ true = "${INERROR}" ]
-then
- rm -rf "${WORK_DIR}"
- exit 1
-fi
-
-
-
-
-
-mkdir -p "${WORK_DIR}/main"
-cd "${WORK_DIR}/main"
-
-DOWNLOAD_URL=$(curl -fsS -H "Authorization: Bearer ${CI_PAGES_TOKEN}" https://api.github.com/repos/${GH_PROJECT_NAME}/actions/artifacts \
- | jq -r '.artifacts
- | map(select(.workflow_run.head_branch=="main" and .name == "pages"))
- | sort_by(.created_at)
- | last
- | .archive_download_url')
-curl -H "Authorization: Bearer ${CI_PAGES_TOKEN}" -LfsSo artifacts.zip "${DOWNLOAD_URL}"
-unzip -o -d public artifacts.zip
-rm artifacts.zip
-if [ -d "public/main" ]
-then
- mv "public/main" "${WORK_DIR}/public/"
-elif [ -d "main" ]
-then
- mv "main" "${WORK_DIR}/public/"
-elif [ -d "public" ]
-then
- mv public "main"
- mv "main" "${WORK_DIR}/public/"
-fi
-cd "${WORK_DIR}"
-rm -rf "${WORK_DIR}/main"
-
-
cat << EOF >> "${WORK_DIR}/public/index.html"
-
- latest from GIT
EOF
+
mv "${WORK_DIR}/public"/* "${DEPLOY_DIR}"