#!/bin/bash set -Eeuo pipefail ROOT="$(git rev-parse --show-toplevel)" cd "$ROOT" CURRENT_BRANCH="$(git branch --show-current)" resolve_remote_name() { local branch="$1" shift || true for arg in "$@"; do case "$arg" in --) break ;; -*) continue ;; *) if git remote get-url "$arg" >/dev/null 2>&1; then echo "$arg" return 0 fi ;; esac done git config --get "branch.${branch}.pushRemote" \ || git config --get remote.pushDefault \ || git config --get "branch.${branch}.remote" \ || echo origin } REMOTE_NAME="$(resolve_remote_name "$CURRENT_BRANCH" "$@")" git push "$@" if [[ "$CURRENT_BRANCH" != "master" ]]; then echo "[meanas docs push] current branch is '${CURRENT_BRANCH:-}' not 'master'; skipping docs publish" >&2 exit 0 fi if [[ "$REMOTE_NAME" != "origin" ]]; then echo "[meanas docs push] push remote is '${REMOTE_NAME}' not 'origin'; skipping docs publish" >&2 exit 0 fi if ! command -v mkdocs >/dev/null 2>&1; then echo "[meanas docs push] mkdocs not found; skipping docs publish" >&2 exit 0 fi DOCS_SITE_URL="${DOCS_SITE_URL:-$(git config --get meanas.docsSiteUrl || true)}" export DOCS_SITE_URL if [[ -n "$DOCS_SITE_URL" ]]; then echo "[meanas docs push] publishing docs for ${DOCS_SITE_URL}" >&2 else echo "[meanas docs push] DOCS_SITE_URL is unset; building docs with relative site_url" >&2 fi echo "[meanas docs push] building docs" >&2 ./make_docs.sh echo "[meanas docs push] publishing docs-site branch" >&2 ./scripts/publish_docs_branch.sh site docs-site