ci: copiar .env ao usar fallback de APP_DIR (HOME)\n\n- Evita excluir .env* quando copiando para o diretório alternativo.\n- Garante que o container tenha envs ao subir fora do /srv.

This commit is contained in:
Esdras Renan 2025-10-09 16:59:18 -03:00
parent 82c16533da
commit 5ff93a354f

View file

@ -87,6 +87,11 @@ jobs:
run: | run: |
mkdir -p "$EFFECTIVE_APP_DIR" mkdir -p "$EFFECTIVE_APP_DIR"
RSYNC_FLAGS="-az --inplace --no-times --no-perms --no-owner --no-group --delete" RSYNC_FLAGS="-az --inplace --no-times --no-perms --no-owner --no-group --delete"
# Excluir .env apenas quando copiando para o diretório padrão (/srv) para preservar segredos locais
EXCLUDE_ENV="--exclude '.env*' --exclude 'apps/desktop/.env*' --exclude 'convex/.env*'"
if [ "$EFFECTIVE_APP_DIR" != "${APP_DIR:-/srv/apps/sistema}" ]; then
EXCLUDE_ENV=""
fi
rsync $RSYNC_FLAGS \ rsync $RSYNC_FLAGS \
--filter='protect node_modules' \ --filter='protect node_modules' \
--filter='protect node_modules/**' \ --filter='protect node_modules/**' \
@ -102,29 +107,8 @@ jobs:
--exclude 'node_modules/**' \ --exclude 'node_modules/**' \
--exclude '.pnpm-store' \ --exclude '.pnpm-store' \
--exclude '.pnpm-store/**' \ --exclude '.pnpm-store/**' \
--exclude '.env*' \ $EXCLUDE_ENV \
--exclude 'apps/desktop/.env*' \ ./ "$EFFECTIVE_APP_DIR"/
--exclude 'convex/.env*' \
./ "$EFFECTIVE_APP_DIR"/ \
|| rsync $RSYNC_FLAGS \
--filter='protect node_modules' \
--filter='protect node_modules/**' \
--filter='protect .pnpm-store' \
--filter='protect .pnpm-store/**' \
--filter='protect .env' \
--filter='protect .env*' \
--filter='protect apps/desktop/.env*' \
--filter='protect convex/.env*' \
--exclude '.git' \
--exclude '.next' \
--exclude 'node_modules' \
--exclude 'node_modules/**' \
--exclude '.pnpm-store' \
--exclude '.pnpm-store/**' \
--exclude '.env*' \
--exclude 'apps/desktop/.env*' \
--exclude 'convex/.env*' \
./ "$EFFECTIVE_APP_DIR"/
- name: Install and build (Next.js) - name: Install and build (Next.js)
run: | run: |
@ -176,6 +160,10 @@ jobs:
run: | run: |
mkdir -p "$EFFECTIVE_APP_DIR" mkdir -p "$EFFECTIVE_APP_DIR"
RSYNC_FLAGS="-az --inplace --no-times --no-perms --no-owner --no-group --delete" RSYNC_FLAGS="-az --inplace --no-times --no-perms --no-owner --no-group --delete"
EXCLUDE_ENV="--exclude '.env*' --exclude 'apps/desktop/.env*' --exclude 'convex/.env*'"
if [ "$EFFECTIVE_APP_DIR" != "${APP_DIR:-/srv/apps/sistema}" ]; then
EXCLUDE_ENV=""
fi
rsync $RSYNC_FLAGS \ rsync $RSYNC_FLAGS \
--filter='protect node_modules' \ --filter='protect node_modules' \
--filter='protect node_modules/**' \ --filter='protect node_modules/**' \
@ -191,29 +179,8 @@ jobs:
--exclude 'node_modules/**' \ --exclude 'node_modules/**' \
--exclude '.pnpm-store' \ --exclude '.pnpm-store' \
--exclude '.pnpm-store/**' \ --exclude '.pnpm-store/**' \
--exclude '.env*' \ $EXCLUDE_ENV \
--exclude 'apps/desktop/.env*' \ ./ "$EFFECTIVE_APP_DIR"/
--exclude 'convex/.env*' \
./ "$EFFECTIVE_APP_DIR"/ \
|| rsync $RSYNC_FLAGS \
--filter='protect node_modules' \
--filter='protect node_modules/**' \
--filter='protect .pnpm-store' \
--filter='protect .pnpm-store/**' \
--filter='protect .env' \
--filter='protect .env*' \
--filter='protect apps/desktop/.env*' \
--filter='protect convex/.env*' \
--exclude '.git' \
--exclude '.next' \
--exclude 'node_modules' \
--exclude 'node_modules/**' \
--exclude '.pnpm-store' \
--exclude '.pnpm-store/**' \
--exclude '.env*' \
--exclude 'apps/desktop/.env*' \
--exclude 'convex/.env*' \
./ "$EFFECTIVE_APP_DIR"/
- name: Deploy functions to Convex self-hosted - name: Deploy functions to Convex self-hosted
run: | run: |
docker run --rm -i \ docker run --rm -i \