forked from canonical/docs.ubuntu.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-docs.sh
executable file
·152 lines (129 loc) · 5.47 KB
/
build-docs.sh
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env bash
set -euo pipefail
refresh_repo() {
folder=$1
repo_url=$2
branch=$3
if [ ! -d "${folder}/.git" ]; then
# Clone project if it doesn't exist in the workspace
git clone -b ${branch} ${repo_url} ${folder}
else
# If it exists, update to the latest commit
(
cd ${folder}
for remote in `git remote`; do git remote rm ${remote}; done
git remote add origin ${repo_url}
git fetch origin
git remote set-head origin ${branch}
git clean -fd
git reset --hard HEAD
git checkout ${branch}
git reset --hard origin/${branch}
)
fi
}
up_to_date() {
folder=$1
repo_url=$2
if [ -d ${folder}/.git ]; then
remote_commit=$(git ls-remote ${repo_url} | grep HEAD | awk '{print $1;}')
local_commit=$(git -C ${folder}/.git rev-parse HEAD)
if [ "${remote_commit}" == "${local_commit}" ]; then
echo "${folder} hasn't changed"
return 0
fi
fi
return 1
}
build_docs () {
mkdir -p build
# Conjure-up docs
folder="build/conjure-up"
name="conjure-up"
repo_url="https://github.com/canonicalltd/docs-conjure-up.git"
if ! up_to_date ${folder} ${repo_url}; then
refresh_repo ${folder} ${repo_url} master
documentation-builder --base-directory "${folder}" \
--site-root "/${name}/" \
--output-path "templates/${name}" \
--output-media-path "static/media/${name}" \
--search-url "/search" \
--search-placeholder "Search ${name} docs" \
--search-domain "docs.ubuntu.com/${name}" \
--build-version-branches \
--media-url "/static/media/${name}" \
--tag-manager-code "GTM-K92JCQ" \
--no-link-extensions
fi
# Documentation-builder
folder="build/documentation-builder"
name="documentation-builder"
repo_url="https://github.com/canonical-webteam/documentation-builder.git"
if ! up_to_date ${folder} ${repo_url}; then
refresh_repo ${folder} ${repo_url} master
documentation-builder --base-directory "${folder}" \
--site-root "/${name}/" \
--output-path "templates/${name}" \
--output-media-path "static/media/${name}" \
--search-url "/search" \
--search-placeholder "Search Builder docs" \
--search-domain "docs.ubuntu.com/${name}" \
--source-folder docs \
--media-url "/static/media/${name}" \
--tag-manager-code "GTM-K92JCQ" \
--no-link-extensions
fi
# MAAS docs
folder="build/maas"
name="maas"
repo_url="https://github.com/canonicalltd/maas-docs.git"
if ! up_to_date ${folder} ${repo_url}; then
refresh_repo ${folder} ${repo_url} master
documentation-builder --base-directory "${folder}" \
--site-root "/${name}/" \
--output-path "templates/${name}" \
--output-media-path "static/media/${name}" \
--search-url "/search" \
--search-placeholder "Search MAAS docs" \
--search-domain "docs.ubuntu.com/${name}" \
--build-version-branches \
--media-url "/static/media/${name}" \
--tag-manager-code "GTM-K92JCQ" \
--no-link-extensions
fi
# Style Guide docs
folder="build/styleguide"
name="styleguide"
repo_url="https://github.com/canonical-docs/praecepta.git"
if ! up_to_date ${folder} ${repo_url}; then
refresh_repo ${folder} ${repo_url} master
documentation-builder --base-directory "${folder}" \
--site-root "/${name}/" \
--output-path "templates/${name}" \
--output-media-path "static/media/${name}" \
--search-url "/search" \
--search-placeholder "Search Style Guide docs" \
--search-domain "docs.ubuntu.com/${name}" \
--media-url "/static/media/${name}" \
--tag-manager-code "GTM-K92JCQ" \
--no-link-extensions
fi
# Landscape docs
folder="build/landscape"
name="landscape"
repo_url="https://github.com/canonicalltd/docs-landscape.git"
if ! up_to_date ${folder} ${repo_url}; then
refresh_repo ${folder} ${repo_url} master
documentation-builder --base-directory "${folder}" \
--site-root "/${name}/" \
--output-path "templates/${name}" \
--output-media-path "static/media/${name}" \
--search-url "/search" \
--search-placeholder "Search Landscape docs" \
--search-domain "docs.ubuntu.com/${name}" \
--media-url "/static/media/${name}" \
--tag-manager-code "GTM-K92JCQ" \
--no-link-extensions
fi
}
build_docs