evol(deploy): run-project-hooks, algo/enso repository_root, wire change-to-all-branches
**Motivations:** - Execute deploy.hooks.phases from conf.json with fallback to deploy_script_path; align algo/enso with repository_root and empty phases. **Root causes:** - Deploy entry was hardcoded to deploy.sh; hooks array unused. **Correctifs:** - None. **Evolutions:** - deploy/run-project-hooks.sh; change-to-all-branches.sh and deploy-by-script-to.sh call it when IA_PROJECT_ID is set; lecoffreio phases list deploy/scripts_v2/deploy.sh; algo/enso repository_root + hooks.phases []; deploy/lib/README.md placeholder for future generic extract. **Pages affectées:** - deploy/run-project-hooks.sh, deploy/change-to-all-branches.sh, deploy/deploy-by-script-to.sh, deploy/lib/README.md, projects/lecoffreio/conf.json, projects/algo/conf.json, projects/enso/conf.json
This commit is contained in:
parent
db5a184851
commit
aa3249ee0c
@ -47,6 +47,10 @@ echo "[change-to-all-branches] Aligning branches..."
|
||||
# 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)..."
|
||||
"${DEPLOY_SCRIPTS_V2}/deploy.sh" test --import-v1 --skipSetupHost --no-sync-origin
|
||||
if [[ -n "${IA_PROJECT_ID:-}" && -x "${DEPLOY_DIR}/run-project-hooks.sh" ]]; then
|
||||
"${DEPLOY_DIR}/run-project-hooks.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"
|
||||
|
||||
@ -66,12 +66,16 @@ git fetch origin
|
||||
git reset --hard "origin/${TARGET_BRANCH}"
|
||||
|
||||
echo "[deploy-by-script-to] Step 4/5: deploy ${TARGET_BRANCH} (--import-v1 --skipSetupHost)..."
|
||||
deploy_script="$PROJECT_ROOT/deploy/scripts_v2/deploy.sh"
|
||||
if [[ -n "${PROJECT_CONFIG_PATH:-}" && -f "${PROJECT_CONFIG_PATH:-}" ]] && command -v jq >/dev/null 2>&1; then
|
||||
_cfg_script="$(jq -r '.deploy.deploy_script_path // ""' "$PROJECT_CONFIG_PATH" 2>/dev/null)"
|
||||
[[ -n "$_cfg_script" && -x "$_cfg_script" ]] && deploy_script="$_cfg_script"
|
||||
if [[ -n "${IA_PROJECT_ID:-}" && -x "${DEPLOY_IA}/run-project-hooks.sh" ]]; then
|
||||
"${DEPLOY_IA}/run-project-hooks.sh" "$TARGET_BRANCH" --import-v1 --skipSetupHost
|
||||
else
|
||||
deploy_script="$PROJECT_ROOT/deploy/scripts_v2/deploy.sh"
|
||||
if [[ -n "${PROJECT_CONFIG_PATH:-}" && -f "${PROJECT_CONFIG_PATH:-}" ]] && command -v jq >/dev/null 2>&1; then
|
||||
_cfg_script="$(jq -r '.deploy.deploy_script_path // ""' "$PROJECT_CONFIG_PATH" 2>/dev/null)"
|
||||
[[ -n "$_cfg_script" && -x "$_cfg_script" ]] && deploy_script="$_cfg_script"
|
||||
fi
|
||||
"$deploy_script" "$TARGET_BRANCH" --import-v1 --skipSetupHost
|
||||
fi
|
||||
"$deploy_script" "$TARGET_BRANCH" --import-v1 --skipSetupHost
|
||||
|
||||
echo "[deploy-by-script-to] Step 5/5: checkout test..."
|
||||
git checkout test
|
||||
|
||||
7
deploy/lib/README.md
Normal file
7
deploy/lib/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Shared deploy helpers (ia_dev)
|
||||
|
||||
LeCoffre conserve la logique métier et SSH ciblée dans `lecoffre_ng_test/deploy/scripts_v2/` (dont `_lib/` : `ssh.sh`, `colors.sh`, modules `deploy-*.sh`).
|
||||
|
||||
Ce répertoire est réservé aux **extraits réellement génériques** (plusieurs projets, sans Prisma ni règles LeCoffre), extraits **après** stabilisation de la segmentation côté projet. Aujourd’hui les helpers SSH/proxy dupliqués ne sont pas déplacés ici pour éviter une double source de vérité avant revue transverse.
|
||||
|
||||
Référence cadrage : dépôt LeCoffre, `deploy/DEPLOY_ORCHESTRATION_IA_DEV.md`.
|
||||
65
deploy/run-project-hooks.sh
Executable file
65
deploy/run-project-hooks.sh
Executable file
@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run deploy.hooks.phases from projects/<id>/conf.json (paths relative to repository_root).
|
||||
# If phases is empty or missing, exec deploy.deploy_script_path with the same arguments.
|
||||
# Usage: run-project-hooks.sh <env> [options passed to each phase / fallback script]
|
||||
# Requires: IA_PROJECT_ID, IA_DEV_ROOT (or re-exec from project root like change-to-all-branches).
|
||||
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)"
|
||||
|
||||
if [[ -z "${IA_PROJECT_ID:-}" ]]; then
|
||||
echo "[run-project-hooks][ERROR] IA_PROJECT_ID is not set" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# shellcheck source=../lib/project_config.sh
|
||||
source "${IA_DEV_ROOT}/lib/project_config.sh"
|
||||
# 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
|
||||
REPO_ROOT="${IA_PROJECT_GIT_ROOT:-}"
|
||||
if [[ -z "$REPO_ROOT" || ! -d "$REPO_ROOT" ]]; then
|
||||
echo "[run-project-hooks][ERROR] Could not resolve repository root for project ${IA_PROJECT_ID}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CONF="${PROJECT_CONFIG_PATH:-}"
|
||||
if [[ -z "$CONF" || ! -f "$CONF" ]]; then
|
||||
echo "[run-project-hooks][ERROR] Missing conf: ${CONF:-}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v jq >/dev/null 2>&1; then
|
||||
echo "[run-project-hooks][ERROR] jq is required to read deploy.hooks.phases" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEPLOY_SCRIPT_PATH="$(jq -r '.deploy.deploy_script_path // empty' "$CONF")"
|
||||
if [[ -z "$DEPLOY_SCRIPT_PATH" || ! -f "$DEPLOY_SCRIPT_PATH" ]]; then
|
||||
echo "[run-project-hooks][ERROR] deploy.deploy_script_path missing or not a file: ${DEPLOY_SCRIPT_PATH:-}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PHASE_COUNT="$(jq '.deploy.hooks.phases // [] | length' "$CONF")"
|
||||
if [[ "$PHASE_COUNT" == "0" ]]; then
|
||||
exec bash "$DEPLOY_SCRIPT_PATH" "$@"
|
||||
fi
|
||||
|
||||
mapfile -t PHASE_SCRIPTS < <(jq -r '.deploy.hooks.phases[]? | if type == "string" then . elif type == "object" and (.run | type == "string") then .run else empty end' "$CONF")
|
||||
|
||||
if [[ ${#PHASE_SCRIPTS[@]} -eq 0 ]]; then
|
||||
exec bash "$DEPLOY_SCRIPT_PATH" "$@"
|
||||
fi
|
||||
|
||||
for rel in "${PHASE_SCRIPTS[@]}"; do
|
||||
[[ -z "$rel" ]] && continue
|
||||
phase_path="${REPO_ROOT}/${rel}"
|
||||
if [[ ! -f "$phase_path" ]]; then
|
||||
echo "[run-project-hooks][ERROR] Phase script not found: ${phase_path}" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "[run-project-hooks] Running: ${rel} $*"
|
||||
bash "$phase_path" "$@"
|
||||
done
|
||||
@ -8,9 +8,13 @@
|
||||
"/home/desk/code/algo/deploy/lecoffre-front-main"
|
||||
],
|
||||
"deploy": {
|
||||
"repository_root": "/home/desk/code/algo",
|
||||
"scripts_path": "/home/desk/code/algo/deploy/scripts_v2",
|
||||
"deploy_script_path": "/home/desk/code/algo/deploy/scripts_v2/deploy.sh",
|
||||
"secrets_path": "/home/desk/code/algo/.secrets"
|
||||
"secrets_path": "/home/desk/code/algo/.secrets",
|
||||
"hooks": {
|
||||
"phases": []
|
||||
}
|
||||
},
|
||||
"version": {
|
||||
"package_json_paths": [
|
||||
|
||||
@ -8,9 +8,13 @@
|
||||
"/home/desk/code/enso/deploy/lecoffre-front-main"
|
||||
],
|
||||
"deploy": {
|
||||
"repository_root": "/home/desk/code/enso",
|
||||
"scripts_path": "/home/desk/code/enso/deploy/scripts_v2",
|
||||
"deploy_script_path": "/home/desk/code/enso/deploy/scripts_v2/deploy.sh",
|
||||
"secrets_path": "/home/desk/code/enso/.secrets"
|
||||
"secrets_path": "/home/desk/code/enso/.secrets",
|
||||
"hooks": {
|
||||
"phases": []
|
||||
}
|
||||
},
|
||||
"version": {
|
||||
"package_json_paths": [
|
||||
|
||||
@ -13,7 +13,9 @@
|
||||
"deploy_script_path": "/home/desk/code/lecoffre_ng_test/deploy/scripts_v2/deploy.sh",
|
||||
"secrets_path": "/home/desk/code/lecoffre_ng_test/.secrets",
|
||||
"hooks": {
|
||||
"phases": []
|
||||
"phases": [
|
||||
"deploy/scripts_v2/deploy.sh"
|
||||
]
|
||||
}
|
||||
},
|
||||
"version": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user