forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.sh
executable file
·43 lines (33 loc) · 1.47 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
#!/usr/bin/env bash
set -e
# This is run on every commit that GitHub Actions picks up. It assumes that docs have already been
# built via docs/build.sh. The commit behavior differs depending on the nature of the commit:
# * Tag commit (e.g. v1.6.0): commits docs to versioned location.
# * Main commit: commits docs to latest. Note that envoy-mobile.github.io uses `master` rather than
# `main` because using `main` as the default branch currently results in 404s.
# * Otherwise: noop.
set -o pipefail
DOCS_DIR=generated/docs
BUILD_SHA="$(git rev-parse HEAD)"
if [[ -z "$MOBILE_DOCS_CHECKOUT_DIR" ]]; then
echo "MOBILE_DOCS_CHECKOUT_DIR is not set, exiting" >&2
exit 1
fi
if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
PUBLISH_DIR="$MOBILE_DOCS_CHECKOUT_DIR"/docs/envoy-mobile/"$GITHUB_REF_NAME"
else
PUBLISH_DIR="$MOBILE_DOCS_CHECKOUT_DIR"/docs/envoy-mobile/latest
fi
echo "Publishing docs in ${PUBLISH_DIR}"
git -C "$MOBILE_DOCS_CHECKOUT_DIR" checkout -B master origin/master
rm -fr "$PUBLISH_DIR"
mkdir -p "$PUBLISH_DIR"
cp -r "$DOCS_DIR"/* "$PUBLISH_DIR"
git -C "${MOBILE_DOCS_CHECKOUT_DIR}" config user.name "envoy-mobile-docs(ci)"
git -C "${MOBILE_DOCS_CHECKOUT_DIR}" config user.email [email protected]
echo 'add'
git -C "${MOBILE_DOCS_CHECKOUT_DIR}" add .
if [[ "$(git -C "${MOBILE_DOCS_CHECKOUT_DIR}" status --porcelain)" ]]; then
echo 'commit'
git -C "${MOBILE_DOCS_CHECKOUT_DIR}" commit -m "docs envoy-mobile@$BUILD_SHA"
fi