fix(pousse): support multisite front builds
Read deploy.default_site_code from project conf and inject NEXT_PUBLIC_SITE_CODE when building front-common. Also align lecoffreio build_dirs and version paths with back-common/front-common/ressources-common.
This commit is contained in:
parent
8a73fea3c8
commit
45992c6145
@ -125,10 +125,12 @@ if [[ "$author_name" != "4NK" && "$author_name" != "Nicolas Cantu" ]]; then
|
|||||||
fi
|
fi
|
||||||
# Build dirs from project config (projects/<id>/conf.json); skip if no config or no build_dirs
|
# Build dirs from project config (projects/<id>/conf.json); skip if no config or no build_dirs
|
||||||
build_dirs=()
|
build_dirs=()
|
||||||
|
default_site_code=""
|
||||||
if [[ -n "${PROJECT_CONFIG_PATH:-}" && -f "$PROJECT_CONFIG_PATH" ]] && command -v jq >/dev/null 2>&1; then
|
if [[ -n "${PROJECT_CONFIG_PATH:-}" && -f "$PROJECT_CONFIG_PATH" ]] && command -v jq >/dev/null 2>&1; then
|
||||||
while IFS= read -r d; do
|
while IFS= read -r d; do
|
||||||
[[ -n "$d" ]] && build_dirs+=( "$d" )
|
[[ -n "$d" ]] && build_dirs+=( "$d" )
|
||||||
done < <(jq -r '.build_dirs[]? // empty' "$PROJECT_CONFIG_PATH" 2>/dev/null)
|
done < <(jq -r '.build_dirs[]? // empty' "$PROJECT_CONFIG_PATH" 2>/dev/null)
|
||||||
|
default_site_code="$(jq -r '.deploy.default_site_code // empty' "$PROJECT_CONFIG_PATH" 2>/dev/null)"
|
||||||
fi
|
fi
|
||||||
if [[ ${#build_dirs[@]} -gt 0 ]]; then
|
if [[ ${#build_dirs[@]} -gt 0 ]]; then
|
||||||
# shellcheck source=../lib/conf_path_resolve.sh
|
# shellcheck source=../lib/conf_path_resolve.sh
|
||||||
@ -146,6 +148,16 @@ if [[ ${#build_dirs[@]} -gt 0 ]]; then
|
|||||||
echo "[pousse][WARN] Skipping build ${dir} (directory not found)" >&2
|
echo "[pousse][WARN] Skipping build ${dir} (directory not found)" >&2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
build_basename="$(basename "$abs_dir")"
|
||||||
|
if [[ -n "$default_site_code" && -z "${NEXT_PUBLIC_SITE_CODE:-}" && ( "$build_basename" == "front-common" || "$build_basename" == "lecoffre-front-main" ) ]]; then
|
||||||
|
echo "[pousse] Building ${dir} (NEXT_PUBLIC_SITE_CODE=${default_site_code})..."
|
||||||
|
(cd "$abs_dir" && env "NEXT_PUBLIC_SITE_CODE=${default_site_code}" npm run build) || {
|
||||||
|
echo "[pousse][ERROR] Build failed in ${dir}" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
echo "[pousse] Building ${dir}..."
|
echo "[pousse] Building ${dir}..."
|
||||||
(cd "$abs_dir" && npm run build) || {
|
(cd "$abs_dir" && npm run build) || {
|
||||||
echo "[pousse][ERROR] Build failed in ${dir}" >&2
|
echo "[pousse][ERROR] Build failed in ${dir}" >&2
|
||||||
|
|||||||
@ -3,9 +3,9 @@
|
|||||||
"name": "Lecoffre.io",
|
"name": "Lecoffre.io",
|
||||||
"project_path": "/home/desk/code/lecoffre_ng_test/deploy",
|
"project_path": "/home/desk/code/lecoffre_ng_test/deploy",
|
||||||
"build_dirs": [
|
"build_dirs": [
|
||||||
"/home/desk/code/lecoffre_ng_test/lecoffre-ressources-dev",
|
"/home/desk/code/lecoffre_ng_test/ressources-common",
|
||||||
"/home/desk/code/lecoffre_ng_test/lecoffre-back-main",
|
"/home/desk/code/lecoffre_ng_test/back-common",
|
||||||
"/home/desk/code/lecoffre_ng_test/lecoffre-front-main"
|
"/home/desk/code/lecoffre_ng_test/front-common"
|
||||||
],
|
],
|
||||||
"deploy": {
|
"deploy": {
|
||||||
"repository_root": "/home/desk/code/lecoffre_ng_test",
|
"repository_root": "/home/desk/code/lecoffre_ng_test",
|
||||||
@ -13,12 +13,13 @@
|
|||||||
"deploy_script_path": "/home/desk/code/lecoffre_ng_test/deploy/scripts_v2/deploy.sh",
|
"deploy_script_path": "/home/desk/code/lecoffre_ng_test/deploy/scripts_v2/deploy.sh",
|
||||||
"project_orchestrator_path": "deploy/scripts_v2/deploy.sh",
|
"project_orchestrator_path": "deploy/scripts_v2/deploy.sh",
|
||||||
"secrets_path": "/home/desk/code/ia_dev/projects/lecoffreio/.secrets",
|
"secrets_path": "/home/desk/code/ia_dev/projects/lecoffreio/.secrets",
|
||||||
|
"default_site_code": "notary",
|
||||||
"host_stays_on_test": true
|
"host_stays_on_test": true
|
||||||
},
|
},
|
||||||
"version": {
|
"version": {
|
||||||
"package_json_paths": [
|
"package_json_paths": [
|
||||||
"/home/desk/code/lecoffre_ng_test/lecoffre-back-main/package.json",
|
"/home/desk/code/lecoffre_ng_test/back-common/package.json",
|
||||||
"/home/desk/code/lecoffre_ng_test/lecoffre-front-main/package.json"
|
"/home/desk/code/lecoffre_ng_test/front-common/package.json"
|
||||||
],
|
],
|
||||||
"splash_app_name": "LeCoffre.io"
|
"splash_app_name": "LeCoffre.io"
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user