blob: 3f5d8e4600a2f31360115c41243e8331094f49de (
plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
#!/bin/sh
TARGET="$1" # The directory that has all the HTML files including versions.
# Usually public/ locally and /site in the Docker image.
VER="$2" # The docs version which is a directory holding all the respective
# versioned site, for example 13.0/
if [ -z "$TARGET" ]; then
echo "Usage: $0 <target> <version>"
echo "Example: $0 public 13.0"
echo "No target provided. Exiting."
exit 1
fi
if [ -z "$VER" ]; then
echo "Usage: $0 <target> <version>"
echo "Example: $0 public 13.0"
echo "No version provided. Exiting."
exit 1
fi
if ! [ -d "$TARGET/$VER" ]; then
echo "Target directory $TARGET/$VER does not exist. Exiting."
exit 1
fi
##
## In order for the version to be correct, we need to replace any occurrences
## of relative or full URLs with the respective version. Basically, prefix
## all top level directories (except archives/) under public/ with the version.
##
##
## Relative URLs
##
echo "Replace relative URLs in $TARGET/$VER for /ee/"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/ee/#="/'"$VER"'/ee/#g'
echo "Replace relative URLs in $TARGET/$VER for /runner/"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/runner/#="/'"$VER"'/runner/#g'
echo "Replace relative URLs in $TARGET/$VER for /omnibus/"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/omnibus/#="/'"$VER"'/omnibus/#g'
echo "Replace relative URLs in $TARGET/$VER for /charts/"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/charts/#="/'"$VER"'/charts/#g'
echo "Replace relative URLs in $TARGET/$VER for /operator/"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/operator/#="/'"$VER"'/operator/#g'
echo "Replace relative URLs in $TARGET/$VER for /assets/"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/assets/#="/'"$VER"'/assets/#g'
echo "Replace relative URLs in $TARGET/$VER for /frontend/"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/frontend/#="/'"$VER"'/frontend/#g'
echo "Replace relative URLs in $TARGET/$VER for /"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#<a href="/">#<a href="/'"$VER"'/">#g'
echo "Replace relative URLs in $TARGET/$VER for opensearch.xml"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/opensearch.xml#="/'"$VER"'/opensearch.xml#g'
##
## Full URLs
##
echo "Replace full URLs in $TARGET/$VER for /ee/"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/ee/#="/'"$VER"'/ee/#g'
echo "Replace full URLs in $TARGET/$VER for /runner/"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/runner/#="/'"$VER"'/runner/#g'
echo "Replace full URLs in $TARGET/$VER for /omnibus/"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/omnibus/#="/'"$VER"'/omnibus/#g'
echo "Replace full URLs in $TARGET/$VER for /charts/"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/charts/#="/'"$VER"'/charts/#g'
echo "Replace full URLs in $TARGET/$VER for /operator/"
find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/operator/#="/'"$VER"'/operator/#g'
echo "Fix URLs inside the sitemap"
find ${TARGET}/$VER -type f -name 'sitemap.xml' -print0 | xargs -0 sed -i 's#docs.gitlab.com/#docs.gitlab.com/'"$VER"'/#g'
##
## In order to have clean URLs, we symlink README.html to index.html.
## That way, visiting https://docs.gitlab.com/ee/ would be the same as
## visiting https://docs.gitlab.com/ee/{README.html,index.html}
## For 13.9 and later, there's a raketask that is run instead of the
## command below. If the raketask is present, skip the command.
##
bundle exec rake -T | grep symlink_readmes
if [ $? -eq 1 ]
then
echo "Symlink all README.html to index.html"
for i in `find ${TARGET}/${VER} -name README.html`; do ln -sf README.html $(dirname $i)/index.html; done
fi
##
## Don't deploy the CE docs since they are identical to the EE ones.
## https://gitlab.com/gitlab-org/gitlab-docs/issues/418
##
echo "Remove CE dir and symlink EE to CE"
if [ -d "${TARGET}/${VER}/ce/" ]; then cd ${TARGET}/${VER} && rm -r ce && ln -s ee ce; fi
|