deploy.sh: fix self-collision in slug check when clone path != slug
The collision check filtered self-matches by /opt/${SLUG}/, which only
works when the on-disk directory matches the URL slug. When the repo is
cloned to a different directory (e.g. /opt/loreal-utilisation-dept/ to
match the Bitbucket repo name while keeping URL slug "utilisation-dept"),
the script flagged its own apache-*.conf as a foreign collision and
refused to redeploy. Filter against \$REPO_ROOT instead, which holds the
actual on-disk path and matches what grep -l emits.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ac9743c696
commit
8e28464bdf
1 changed files with 5 additions and 2 deletions
|
|
@ -139,11 +139,14 @@ docker compose version >/dev/null 2>&1 || { err "docker compose v2 required"; ex
|
|||
VHOST=/etc/apache2/sites-enabled/optical-dev.oliver.solutions.conf
|
||||
if [[ -r "$VHOST" ]]; then
|
||||
# 1. Slug collision: is another app already claiming /utilisation-dept/?
|
||||
# Look at the live vhost AND every sibling app's apache-*.conf.
|
||||
# Look at the live vhost AND every sibling app's apache-*.conf,
|
||||
# filtering out our OWN conf (matched on REPO_ROOT, not SLUG, since
|
||||
# the on-disk path may not match the URL slug — e.g. cloned to
|
||||
# /opt/loreal-utilisation-dept/ with slug "utilisation-dept").
|
||||
sibling_confs=(/opt/*/deploy/apache-*.conf)
|
||||
collision=$(grep -lE "(ProxyPass|Alias)[[:space:]]+${URL_PATH}/" \
|
||||
"$VHOST" "${sibling_confs[@]}" 2>/dev/null \
|
||||
| grep -v "/opt/${SLUG}/" || true)
|
||||
| grep -vF "${REPO_ROOT}/" || true)
|
||||
if [[ -n "$collision" ]]; then
|
||||
err "Another app claims ${URL_PATH}/ in:"
|
||||
echo "$collision" | sed 's/^/ /' >&2
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue