ci(web): publish build to stable path (/home/renan/apps/sistema) and deploy using that fixed APP_DIR; cleanup only web.build.*

This commit is contained in:
Esdras Renan 2025-10-16 14:53:59 -03:00
parent 9c498245e9
commit 009291f6a2

View file

@ -178,13 +178,13 @@ jobs:
pnpm prisma:generate
pnpm build
- name: Update stable symlink for APP_DIR
- name: Publish build to stable APP_DIR directory
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")"
DEST="$HOME/apps/sistema"
mkdir -p "$DEST"
rsync -a --delete "$EFFECTIVE_APP_DIR"/ "$DEST"/
echo "Published build to: $DEST"
- name: Swarm deploy (stack.yml)
run: |
@ -193,12 +193,12 @@ jobs:
set -o allexport
if [ -f .env ]; then . ./.env; fi
set +o allexport
APP_DIR_RESOLVED="$(readlink -f "$HOME/apps/sistema.current" || true)"
if [ -z "$APP_DIR_RESOLVED" ] || [ ! -d "$APP_DIR_RESOLVED" ]; then
echo "ERROR: Resolved APP_DIR does not exist: $APP_DIR_RESOLVED" >&2; exit 1
APP_DIR_STABLE="$HOME/apps/sistema"
if [ ! -d "$APP_DIR_STABLE" ]; then
echo "ERROR: Stable APP_DIR does not exist: $APP_DIR_STABLE" >&2; exit 1
fi
echo "Using APP_DIR (resolved)=$APP_DIR_RESOLVED"
APP_DIR="$APP_DIR_RESOLVED" RELEASE_SHA=${{ github.sha }} docker stack deploy --with-registry-auth -c stack.yml sistema
echo "Using APP_DIR (stable)=$APP_DIR_STABLE"
APP_DIR="$APP_DIR_STABLE" RELEASE_SHA=${{ github.sha }} docker stack deploy --with-registry-auth -c stack.yml sistema
- name: Ensure Convex service envs and restart
run: |
@ -254,7 +254,7 @@ jobs:
ROOT="$HOME/apps"
KEEP=2
PATTERN='web.build.*'
ACTIVE="$(readlink -f "$HOME/apps/sistema.current" 2>/dev/null || echo)"
ACTIVE="$HOME/apps/sistema"
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