Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ By: \`${{ github.actor }}\`"
runs-on: ubuntu-latest
needs: quality-gates
if: needs.quality-gates.result == 'success'
environment:
name: production

env:
DEPLOY_PASS: ${{ secrets.DEPLOY_PASS }}
Expand Down
21 changes: 11 additions & 10 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@ say "Date: $(date -u '+%Y-%m-%dT%H:%M:%SZ')"
cd "$PROJECT_DIR"

# ---------------------------------------------------------
# Load only the variables needed for Telegram notifications.
# Using set -o allexport would export every line in .env
# (including unrelated or potentially sensitive variables).
# Instead, extract only BOT_TOKEN and ADMIN_IDS explicitly.
# ---------------------------------------------------------
if [[ -f "$PROJECT_DIR/.env" ]]; then
_env_file="$PROJECT_DIR/.env"
BOT_TOKEN="$(grep -E '^BOT_TOKEN=' "$_env_file" | head -1 | cut -d= -f2- | tr -d '"'"'"' | tr -d $'\r')" || true
ADMIN_IDS="$(grep -E '^ADMIN_IDS=' "$_env_file" | head -1 | cut -d= -f2- | tr -d '"'"'"' | tr -d $'\r')" || true
export BOT_TOKEN ADMIN_IDS
# Load BOT_TOKEN and ADMIN_IDS for Telegram notifications.
# When deploy.sh is spawned from the bot process (source=bot),
# these are already inherited via process.env — don't overwrite.
# When invoked from GitHub Actions or a cron, parse from .env.
# ---------------------------------------------------------
if [[ -z "${BOT_TOKEN:-}" && -f "$PROJECT_DIR/.env" ]]; then
BOT_TOKEN="$(grep -E '^BOT_TOKEN=' "$PROJECT_DIR/.env" | head -1 | cut -d= -f2- | sed "s/^['\"]//;s/['\"]$//" | tr -d $'\r')" || true
fi
if [[ -z "${ADMIN_IDS:-}" && -f "$PROJECT_DIR/.env" ]]; then
ADMIN_IDS="$(grep -E '^ADMIN_IDS=' "$PROJECT_DIR/.env" | head -1 | cut -d= -f2- | sed "s/^['\"]//;s/['\"]$//" | tr -d $'\r')" || true
fi
export BOT_TOKEN ADMIN_IDS

# ---------------------------------------------------------
# Silent Telegram admin notification helper
Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2623,11 +2623,17 @@ bot.command('deploy', async (ctx) => {

// Spawn deploy.sh detached — it stops + restarts the service,
// sends per-step Telegram notifications via curl, and handles errors.
// Pass the bot's full environment so deploy.sh inherits BOT_TOKEN and
// ADMIN_IDS and its send_admin() calls actually reach Telegram.
const deployScript = path.join(PROJECT_DIR, 'deploy.sh');
const deployProc = spawn('bash', [deployScript, 'bot'], {
detached: true,
stdio: 'ignore',
cwd: PROJECT_DIR,
env: {
...process.env,
PATH: process.env.PATH || '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
},
});
deployProc.unref();

Expand Down
2 changes: 1 addition & 1 deletion scripts/disk-protect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fi
# ── 5. Clear npm cache ─────────────────────────────────────────────────────────
log "Step 5: Clear npm cache"
if command -v npm >/dev/null 2>&1; then
npm cache clean --force 2>&1 | tail -1 | while IFS= read -r line; do log " [npm] $line"; done
npm cache clean --force 2>&1 | tail -1 | while IFS= read -r line; do log " [npm] $line"; done || true
log " npm cache cleared"
else
log " npm not found — skipping"
Expand Down
Loading