**Motivations:** - Single generic orchestration in ia_dev while business logic stays in each project repo **Root causes:** - N/A (evolution) **Correctifs:** - N/A **Evolutions:** - Add orchestrator.sh (deploy.hooks.phases or fallback deploy.deploy_script_path) - Add deploy.sh <project_id> <env> [options] as canonical entry from ia_dev root - run-project-hooks.sh execs orchestrator.sh for backward compatibility - change-to-all-branches.sh and deploy-by-script-to.sh invoke orchestrator.sh when IA_PROJECT_ID is set - Document orchestration in README.md and deploy/lib/README.md **Pages affectées:** - README.md, deploy/orchestrator.sh, deploy/deploy.sh, deploy/run-project-hooks.sh, deploy/change-to-all-branches.sh, deploy/deploy-by-script-to.sh, deploy/lib/README.md
57 lines
2.4 KiB
Bash
Executable File
57 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# From branch test only: align origin/test, origin/pprod, origin/prod then deploy to test (import-v1, skipSetupHost).
|
|
# Usage: ./deploy/change-to-all-branches.sh [project_id]
|
|
set -euo pipefail
|
|
|
|
SCRIPT_REAL="$(readlink -f "${BASH_SOURCE[0]:-$0}" 2>/dev/null || realpath "${BASH_SOURCE[0]:-$0}" 2>/dev/null || echo "${BASH_SOURCE[0]:-$0}")"
|
|
DEPLOY_DIR="$(cd "$(dirname "$SCRIPT_REAL")" && pwd)"
|
|
IA_DEV_ROOT="$(cd "$DEPLOY_DIR/.." && pwd)"
|
|
|
|
# Optional first arg: project id (must exist as projects/<id>/conf.json); then re-exec from project root
|
|
if [[ -n "${1:-}" && -f "${IA_DEV_ROOT}/projects/${1}/conf.json" ]]; then
|
|
export IA_PROJECT_ID="$1"
|
|
shift
|
|
# shellcheck source=../lib/project_config.sh
|
|
source "${IA_DEV_ROOT}/lib/project_config.sh"
|
|
[[ -n "${PROJECT_ID:-}" ]] && export IA_PROJECT_ID="$PROJECT_ID"
|
|
# shellcheck source=../lib/project_git_root_from_conf.sh
|
|
source "${IA_DEV_ROOT}/lib/project_git_root_from_conf.sh"
|
|
ia_dev_resolve_project_git_root
|
|
PROJECT_ROOT="${IA_PROJECT_GIT_ROOT:-}"
|
|
if [[ -z "$PROJECT_ROOT" || ! -d "$PROJECT_ROOT" ]]; then
|
|
echo "[change-to-all-branches][ERROR] Could not resolve project root for project_id ${IA_PROJECT_ID}" >&2
|
|
exit 1
|
|
fi
|
|
cd "$PROJECT_ROOT" && exec "${DEPLOY_DIR}/$(basename "${BASH_SOURCE[0]:-$0}")" "$@"
|
|
fi
|
|
|
|
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
echo "[change-to-all-branches][ERROR] Not in a git repository" >&2
|
|
exit 1
|
|
fi
|
|
|
|
PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
|
if [[ "$(pwd)" != "$PROJECT_ROOT" ]]; then
|
|
cd "$PROJECT_ROOT" && exec "${DEPLOY_DIR}/$(basename "${BASH_SOURCE[0]:-$0}")" "$@"
|
|
fi
|
|
|
|
current="$(git rev-parse --abbrev-ref HEAD)"
|
|
if [[ "$current" != "test" ]]; then
|
|
echo "[change-to-all-branches][ERROR] Must be on branch 'test' (current: '${current}')" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "[change-to-all-branches] Aligning branches..."
|
|
"$DEPLOY_DIR/branch-align.sh" test
|
|
|
|
# scripts_v2 lives in the host project's deploy/ (not necessarily under ia_dev)
|
|
DEPLOY_SCRIPTS_V2="${PROJECT_ROOT}/deploy/scripts_v2"
|
|
echo "[change-to-all-branches] Deploying test (--import-v1 --skipSetupHost, --no-sync-origin because we just pushed)..."
|
|
if [[ -n "${IA_PROJECT_ID:-}" && -x "${DEPLOY_DIR}/orchestrator.sh" ]]; then
|
|
"${DEPLOY_DIR}/orchestrator.sh" test --import-v1 --skipSetupHost --no-sync-origin
|
|
else
|
|
"${DEPLOY_SCRIPTS_V2}/deploy.sh" test --import-v1 --skipSetupHost --no-sync-origin
|
|
fi
|
|
|
|
echo "[change-to-all-branches] OK"
|