Fix Bitbucket auth migration in deploy workflow
This commit is contained in:
15
deploy.sh
15
deploy.sh
@@ -16,6 +16,18 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ensure_bitbucket_ssh_remote() {
|
||||
local repo_path=$1
|
||||
local remote_url
|
||||
local remote_path
|
||||
|
||||
remote_url=$(git -C "$repo_path" remote get-url origin)
|
||||
if [[ "$remote_url" =~ ^https://([^@/]+@)?bitbucket\.org/(.+)$ ]]; then
|
||||
remote_path=${BASH_REMATCH[2]}
|
||||
git -C "$repo_path" remote set-url origin "git@bitbucket.org:${remote_path}"
|
||||
fi
|
||||
}
|
||||
|
||||
ENV=${1:-}
|
||||
if [ -z "$ENV" ]; then
|
||||
echo "Usage: $0 <prod|test> [app_branch] [api_branch]"
|
||||
@@ -55,14 +67,17 @@ echo ""
|
||||
|
||||
# --- Pull repos ---
|
||||
echo "[1/4] Pulling container env..."
|
||||
ensure_bitbucket_ssh_remote "$COMPOSE_DIR"
|
||||
git -C "$COMPOSE_DIR" pull --ff-only
|
||||
|
||||
echo ""
|
||||
echo "[2/4] Pulling app ($APP_BRANCH)..."
|
||||
ensure_bitbucket_ssh_remote "$APP_DIR"
|
||||
git -C "$APP_DIR" pull --ff-only origin "$APP_BRANCH"
|
||||
|
||||
echo ""
|
||||
echo "[3/4] Pulling API ($API_BRANCH)..."
|
||||
ensure_bitbucket_ssh_remote "$API_DIR"
|
||||
git -C "$API_DIR" pull --ff-only origin "$API_BRANCH"
|
||||
|
||||
# --- Build and deploy ---
|
||||
|
||||
Reference in New Issue
Block a user