From 03d31d082cd5c9421095a5374f0bf2c48bb84eb6 Mon Sep 17 00:00:00 2001 From: Esdras Renan Date: Thu, 16 Oct 2025 13:37:12 -0300 Subject: [PATCH] ci(web): use stable symlink APP_DIR (/home/renan/apps/sistema.current) and skip active dir during cleanup to prevent mount path disappearance --- .github/workflows/ci-cd-web-desktop.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd-web-desktop.yml b/.github/workflows/ci-cd-web-desktop.yml index d829925..a3011a3 100644 --- a/.github/workflows/ci-cd-web-desktop.yml +++ b/.github/workflows/ci-cd-web-desktop.yml @@ -178,6 +178,14 @@ jobs: pnpm prisma:generate pnpm build + - name: Update stable symlink for APP_DIR + run: | + set -e + LINK="$HOME/apps/sistema.current" + mkdir -p "$(dirname "$LINK")" + ln -sfn "$EFFECTIVE_APP_DIR" "$LINK" + echo "Symlink set: $LINK -> $(readlink -f "$LINK")" + - name: Swarm deploy (stack.yml) run: | cd "$EFFECTIVE_APP_DIR" @@ -185,7 +193,7 @@ jobs: set -o allexport if [ -f .env ]; then . ./.env; fi set +o allexport - APP_DIR="$EFFECTIVE_APP_DIR" RELEASE_SHA=${{ github.sha }} docker stack deploy --with-registry-auth -c stack.yml sistema + APP_DIR="$HOME/apps/sistema.current" RELEASE_SHA=${{ github.sha }} docker stack deploy --with-registry-auth -c stack.yml sistema - name: Ensure Convex service envs and restart run: | @@ -241,11 +249,15 @@ jobs: ROOT="$HOME/apps" KEEP=2 PATTERN='web.build.*' + ACTIVE="$(readlink -f "$HOME/apps/sistema.current" 2>/dev/null || echo)" echo "Scanning $ROOT for old $PATTERN dirs" LIST=$(find "$ROOT" -maxdepth 1 -type d -name "$PATTERN" | sort -r || true) echo "$LIST" | sed -n "1,${KEEP}p" | sed 's/^/Keeping: /' || true echo "$LIST" | sed "1,${KEEP}d" | while read dir; do [ -z "$dir" ] && continue + if [ -n "$ACTIVE" ] && [ "$(readlink -f "$dir")" = "$ACTIVE" ]; then + echo "Skipping active dir (in use by APP_DIR): $dir"; continue + fi echo "Removing $dir" rm -rf "$dir" || { echo "Local rm failed, falling back to docker (root) cleanup for $dir..."