forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.sh
executable file
·49 lines (38 loc) · 1.41 KB
/
publish.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
#!/bin/bash
# This is run on every commit that Azure Pipelines picks up. It assumes that docs have already been built
# via docs/build.sh. The push behavior differs depending on the nature of the commit:
# * Tag commit (e.g. v1.6.0): pushes docs to versioned location, e.g.
# https://www.envoyproxy.io/docs/envoy/v1.6.0/.
# * Master commit: pushes docs to https://www.envoyproxy.io/docs/envoy/latest/.
# * Otherwise: noop.
set -e
DOCS_DIR=generated/docs
CHECKOUT_DIR=envoy-docs
BUILD_SHA=$(git rev-parse HEAD)
MAIN_BRANCH="refs/heads/main"
RELEASE_TAG_REGEX="^refs/tags/v.*"
if [[ "${AZP_BRANCH}" =~ ${RELEASE_TAG_REGEX} ]]; then
PUBLISH_DIR="${CHECKOUT_DIR}"/docs/envoy/"${AZP_BRANCH/refs\/tags\//}"
elif [[ "$AZP_BRANCH" == "${MAIN_BRANCH}" ]]; then
if [[ -n "$NETLIFY_TRIGGER_URL" ]]; then
echo "Triggering netlify docs build for (${BUILD_SHA})"
curl -X POST -d "$BUILD_SHA" "$NETLIFY_TRIGGER_URL"
fi
exit 0
else
echo "Ignoring docs push"
exit 0
fi
DOCS_MAIN_BRANCH="main"
echo 'cloning'
git clone [email protected]:envoyproxy/envoy-website "${CHECKOUT_DIR}" -b "${DOCS_MAIN_BRANCH}" --depth 1
rm -fr "$PUBLISH_DIR"
mkdir -p "$PUBLISH_DIR"
cp -r "$DOCS_DIR"/* "$PUBLISH_DIR"
cd "${CHECKOUT_DIR}"
git config user.name "envoy-docs(Azure Pipelines)"
git config user.email [email protected]
set -x
git add .
git commit -m "docs envoy@$BUILD_SHA"
git push origin "${DOCS_MAIN_BRANCH}"