Add Ubuntu deployment workflow
This commit is contained in:
Executable
+67
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# 适合 README 中 curl | bash 的安装入口。
|
||||
# 它只负责 clone/pull 仓库,然后调用仓库内 scripts/deploy-ubuntu.sh。
|
||||
|
||||
REPO="${REPO:-git@git.n.xiaomi.com:wuyang6/zk-data-agent.git}"
|
||||
BRANCH="${BRANCH:-main}"
|
||||
APP_DIR="${APP_DIR:-${HOME}/zk-data-agent}"
|
||||
FORCE=0
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: bash install-from-git.sh [--repo REPO] [--branch BRANCH] [--dir APP_DIR] [--force]
|
||||
EOF
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--repo)
|
||||
REPO="$2"
|
||||
shift 2
|
||||
;;
|
||||
--branch)
|
||||
BRANCH="$2"
|
||||
shift 2
|
||||
;;
|
||||
--dir)
|
||||
APP_DIR="$2"
|
||||
shift 2
|
||||
;;
|
||||
--force)
|
||||
FORCE=1
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unexpected argument: $1" >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
command -v git >/dev/null 2>&1 || {
|
||||
echo "Missing git. Please install git first." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ -d "${APP_DIR}/.git" ]]; then
|
||||
cd "${APP_DIR}"
|
||||
git fetch origin
|
||||
git checkout "${BRANCH}"
|
||||
if [[ "${FORCE}" == "1" ]]; then
|
||||
git reset --hard "origin/${BRANCH}"
|
||||
else
|
||||
git pull --ff-only origin "${BRANCH}"
|
||||
fi
|
||||
else
|
||||
git clone --branch "${BRANCH}" "${REPO}" "${APP_DIR}"
|
||||
cd "${APP_DIR}"
|
||||
fi
|
||||
|
||||
bash scripts/deploy-ubuntu.sh "${BRANCH}" --skip-git
|
||||
Reference in New Issue
Block a user