deploy(M00-E): 完善菜单式部署骨架
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# shellcheck source=lib.sh
|
||||
. "${SCRIPT_DIR}/lib.sh"
|
||||
# shellcheck source=repo-status.sh
|
||||
. "${SCRIPT_DIR}/repo-status.sh"
|
||||
|
||||
qipai_deploy_business() {
|
||||
qipai_require_root_for_write
|
||||
local repo_dir release_id release_dir manifest
|
||||
repo_dir="$(qipai_repo_dir)"
|
||||
|
||||
if [ ! -d "${repo_dir}/.git" ]; then
|
||||
qipai_info "cloning repository to ${repo_dir}"
|
||||
git clone --branch "$QIPAI_BRANCH" "$QIPAI_REPO_URL" "$repo_dir"
|
||||
fi
|
||||
|
||||
qipai_repo_status
|
||||
git -C "$repo_dir" pull --ff-only origin "$QIPAI_BRANCH"
|
||||
|
||||
release_id="$(date +%Y%m%d%H%M%S)-$(git -C "$repo_dir" rev-parse --short HEAD)"
|
||||
release_dir="$(qipai_release_dir)/${release_id}"
|
||||
mkdir -p "$release_dir"
|
||||
|
||||
manifest="${release_dir}/release.json"
|
||||
cat >"$manifest" <<EOF
|
||||
{
|
||||
"releaseId": "${release_id}",
|
||||
"generatedAt": "$(qipai_timestamp)",
|
||||
"commit": "$(git -C "$repo_dir" rev-parse HEAD)",
|
||||
"branch": "${QIPAI_BRANCH}",
|
||||
"backendBuild": "SKIPPED_NO_PROJECT",
|
||||
"adminBuild": "SKIPPED_NO_PROJECT",
|
||||
"miniappMirror": "RECORDED_SOURCE_COMMIT_ONLY",
|
||||
"databaseMigration": "SKIPPED_NO_MIGRATIONS",
|
||||
"deployed": false
|
||||
}
|
||||
EOF
|
||||
ln -sfn "$release_dir" "${APP_ROOT}/current-release"
|
||||
cp "$manifest" "$(qipai_current_release_file)"
|
||||
qipai_pass "release manifest written: $manifest"
|
||||
qipai_warn "business build is a safe M00 dry run until backend/admin projects exist"
|
||||
}
|
||||
|
||||
if [ "${1:-}" = "--run" ]; then
|
||||
qipai_deploy_business
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user