-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathimport_docs.sh
More file actions
executable file
·58 lines (46 loc) · 1.45 KB
/
import_docs.sh
File metadata and controls
executable file
·58 lines (46 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
# Verify we are working on the root of the repo
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
cd "${REPO_ROOT}"
# Require a version to be specified
if [ "$#" -ne 1 ]; then
echo "Usage: hack/import_docs.sh release-version"
echo ""
echo "e.g. hack/import_docs.sh 1.15"
exit 1
fi
# Set target directory
release_version=${1#v}
DOCDIR=$REPO_ROOT/assets/documentation
TARGETDIR=$DOCDIR/$release_version
# Create a temporary folder in which to clone the CNPG branch
WORKDIR=$(mktemp -d)
mkdir -p $WORKDIR/cnpg
# Clone the branch
git clone --depth 1 --branch release-$release_version git@github.com:cloudnative-pg/cloudnative-pg.git $WORKDIR/cnpg
mkdir -p $TARGETDIR
pushd $WORKDIR/cnpg/docs
docker run --rm -v "$(pwd):$(pwd)" -w "$(pwd)" \
-v "$TARGETDIR:/var/cnpg" \
minidocks/mkdocs \
mkdocs build -v -d /var/cnpg
popd
rm -rf $WORKDIR
if [ ! -f content/docs/$release_version.md ]
then
hugo new docs/$release_version.md
git add content/docs/$release_version.md
fi
# Detect the current version (one with the highest release number)
current_version=$(ls $DOCDIR | sort -n | tail -1)
if [ -d $DOCDIR/current ]
then
git rm -fr $DOCDIR/current
fi
# Copy the last available doc folder as 'current'
# This is a hack as with GH Pages it is not possible
# to issue server-side redirects
cp -a $DOCDIR/$current_version $DOCDIR/current
git add $DOCDIR/current
git add $TARGETDIR