Skip to content
Snippets Groups Projects
Verified Commit 4d24cf1a authored by Martin Weise's avatar Martin Weise
Browse files

Merge branch 'master' into release-latest

parents 731b680a ff397504
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
OVERRIDES_MAIN_HTML=""
SCRIPTS_EXTRA_JS=""
function generate_docs {
BRANCH="release-$1"
echo "==================================================="
echo "Building DOCS for version $1 on branch $2"
echo "Building DOCS for version $1 on branch $BRANCH"
echo "==================================================="
git checkout "$2"
pip install -r ./requirements.txt
git reset --hard && git checkout "$BRANCH"
pip install -r ./requirements.txt > /dev/null
mkdir -p ./final
if [ "$1" = "latest" ]; then
sed -i -e "s/__APPVERSION__/${APP_VERSION}/g" .docs/redirect.html
cp ./.docs/redirect.html ./final/index.html
OVERRIDES_MAIN_HTML=$(cat .docs/overrides/main.html)
sed -i -e "s/__APPVERSION__/${APP_VERSION}/g" .docs/scripts/extra.js
SCRIPTS_EXTRA_JS=$(cat .docs/scripts/extra.js)
else
echo $OVERRIDES_MAIN_HTML > .docs/overrides/main.html
mkdir -p .docs/scripts
echo $SCRIPTS_EXTRA_JS > .docs/scripts/extra.js
fi
find .docs/ -type f -exec sed -i -e "s/__APPVERSION__/$1/g" {} \;
find .docs/ -type f -exec sed -i -e "s/__CHARTVERSION__/$1/g" {} \;
mkdocs build && cp -r ./site "./final/$1"
mkdocs build > /dev/null && cp -r ./site "./final/$1"
cp -r "./swagger/$1" "./final/$1/swagger"
}
function generate_api {
BRANCH="release-$1"
echo "==================================================="
echo "Building API for version $1 on branch $2"
echo "Building API for version $1 on branch $BRANCH"
echo "==================================================="
git checkout "$2"
git reset --hard && git checkout "$BRANCH"
bash .docs/.swagger/swagger-site.sh
find ./site -type f -exec sed -i -e "s/__APPVERSION__/$1/g" {} \;
mkdir -p "./swagger/$1"
......@@ -29,34 +39,37 @@ function generate_api {
}
# usage
if [ -z "$v1_TAGS" ]; then
echo "Variable v1_TAGS not set"
if [ -z "$VERSIONS" ]; then
echo "Variable VERSIONS not set"
exit 1
fi
tags=(${v1_TAGS//,/ })
versions=(${VERSIONS//,/ })
# usage
if [ -z "$APP_VERSION" ]; then
echo "Variable APP_VERSION not set"
exit 2
fi
echo "==================================================="
echo "APP_VERSION=$APP_VERSION"
for i in "${!tags[@]}"; do
version="${tags[i]}"
echo " ~> $version"
done
echo " ~> latest"
echo "==================================================="
# ensure branches exist on machine
git fetch
# tags
for i in "${!tags[@]}"; do
version="${tags[i]}"
generate_api "$version" "v$version"
generate_docs "$version" "v$version"
generate_api "latest"
generate_docs "latest"
# versions
for i in "${!versions[@]}"; do
version="${versions[i]}"
generate_api "$version"
generate_docs "$version"
done
# master
generate_api "latest" "master"
generate_docs "latest" "master"
# finalization
echo "==================================================="
echo "Moving default version $APP_VERSION docs to /"
cp -r ./final/${APP_VERSION}/* ./final/
echo "==================================================="
......@@ -5,7 +5,7 @@
<head>
<meta charset="UTF-8">
<title>Redirect Notice</title>
<meta http-equiv="Refresh" content="0; url='https://www.ifs.tuwien.ac.at/infrastructures/dbrepo/__APPVERSION__/'" />
<meta http-equiv="Refresh" content="0; url='/infrastructures/dbrepo/__APPVERSION__/'" />
</head>
<body>
<h1>Redirect Notice</h1>
......@@ -14,7 +14,7 @@
available at:
</p>
<p>
<a href="https://www.ifs.tuwien.ac.at/infrastructures/dbrepo/__APPVERSION__/">https://www.ifs.tuwien.ac.at/infrastructures/dbrepo/__APPVERSION__/</a>
<a href="/infrastructures/dbrepo/__APPVERSION__/">/infrastructures/dbrepo/__APPVERSION__/</a>
</p>
</body>
</html>
\ No newline at end of file
function getVersion() {
const segments = location.pathname.split('/');
if (segments.length >= 4) {
if (segments.length > 4) {
console.debug('version', segments[3]);
return segments[3];
} else {
console.debug('default version', '__APPVERSION__');
return '__APPVERSION__';
}
}
......
......@@ -719,7 +719,7 @@ docs-1.4.0:
- release-v1.3
- release-v1.4
script:
- apt-get update && apt-get install -y git make sed wget
- apt-get update && apt-get install -y git
- git fetch --tags && git checkout v1.4.0
- pip install -r ./requirements.txt
- wget https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/dev/.docs/overrides/main.html -O .docs/overrides/main.html -q
......
FROM python:3.11-slim as build
WORKDIR /app
RUN apt-get update && apt-get install -y git
ENV VERSIONS="1.4.1,1.4.0,1.3.0"
ENV APP_VERSION="1.4.1"
COPY .git/ .git/
COPY .docs/ .docs/
COPY ./requirements.txt ./requirements.txt
RUN bash .docs/build-website.sh
FROM nginx as runtime
WORKDIR /usr/share/nginx/html/infrastructures/dbrepo/
COPY --from=build /app/final /usr/share/nginx/html/infrastructures/dbrepo/
\ No newline at end of file
......@@ -10,6 +10,13 @@ volumes:
storage-service-data:
services:
website:
restart: "no"
image: website
build: .
ports:
- 8000:80
dbrepo-metadata-db:
restart: "no"
container_name: dbrepo-metadata-db
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment