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
14 changes: 8 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ jobs:

- name: Sync preview Worker secrets
run: |
node -e "const fs=require('fs'); const payload=Object.fromEntries(Object.entries({ BOT_TOKEN: process.env.TEST_BOT_TOKEN, ADMIN_TOKEN: process.env.ADMIN_TOKEN, TELEGRAM_WEBHOOK_SECRET: process.env.TEST_TELEGRAM_WEBHOOK_SECRET || process.env.TELEGRAM_WEBHOOK_SECRET || undefined }).filter(([, value]) => value)); fs.writeFileSync('.cloudflare-secrets.json', JSON.stringify(payload));"
npx wrangler secret bulk .cloudflare-secrets.json --config packages/bot-worker/wrangler.toml --env preview
rm .cloudflare-secrets.json
secrets_file="$(mktemp)"
trap 'rm -f "$secrets_file"' EXIT
SECRETS_FILE="$secrets_file" node -e "const fs=require('fs'); const payload=Object.fromEntries(Object.entries({ BOT_TOKEN: process.env.TEST_BOT_TOKEN, ADMIN_TOKEN: process.env.ADMIN_TOKEN, TELEGRAM_WEBHOOK_SECRET: process.env.TEST_TELEGRAM_WEBHOOK_SECRET || process.env.TELEGRAM_WEBHOOK_SECRET || undefined }).filter(([, value]) => value)); fs.writeFileSync(process.env.SECRETS_FILE, JSON.stringify(payload));"
npx wrangler secret bulk "$secrets_file" --config packages/bot-worker/wrangler.jsonc --env preview

- name: Register preview test bot webhook
if: ${{ env.PREVIEW_WORKER_URL != '' }}
Expand Down Expand Up @@ -161,9 +162,10 @@ jobs:

- name: Sync production Worker secrets
run: |
node -e "const fs=require('fs'); const payload=Object.fromEntries(Object.entries({ BOT_TOKEN: process.env.BOT_TOKEN, ADMIN_TOKEN: process.env.ADMIN_TOKEN, TELEGRAM_WEBHOOK_SECRET: process.env.TELEGRAM_WEBHOOK_SECRET || undefined }).filter(([, value]) => value)); fs.writeFileSync('.cloudflare-secrets.json', JSON.stringify(payload));"
npx wrangler secret bulk .cloudflare-secrets.json --config packages/bot-worker/wrangler.toml --env production
rm .cloudflare-secrets.json
secrets_file="$(mktemp)"
trap 'rm -f "$secrets_file"' EXIT
SECRETS_FILE="$secrets_file" node -e "const fs=require('fs'); const payload=Object.fromEntries(Object.entries({ BOT_TOKEN: process.env.BOT_TOKEN, ADMIN_TOKEN: process.env.ADMIN_TOKEN, TELEGRAM_WEBHOOK_SECRET: process.env.TELEGRAM_WEBHOOK_SECRET || undefined }).filter(([, value]) => value)); fs.writeFileSync(process.env.SECRETS_FILE, JSON.stringify(payload));"
npx wrangler secret bulk "$secrets_file" --config packages/bot-worker/wrangler.jsonc --env production

- name: Register Telegram webhook
env:
Expand Down
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ and recurring pitfalls only.
branch preview alias; do not fall back to the production Web UI origin.
- Do not hard-code private preview or production hostnames in repo config,
workflows, bot links, or `site-config.mjs`.
- Worker and Pages Wrangler configs are JSONC. Keep dynamic deploy-only
bindings, such as the resolved `SDK_EMOJI_KV` namespace id, in generated
temporary config files rather than hard-coding resource ids.
- Windows Node deploy scripts must spawn command shims explicitly, such as
`npm.cmd` and `node_modules/.bin/wrangler.cmd`.

Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ npm run pages:dev
Configure Worker secrets:

```bash
npx wrangler secret put BOT_TOKEN --config packages/bot-worker/wrangler.toml --env production
npx wrangler secret put BOT_TOKEN --config packages/bot-worker/wrangler.toml --env preview
npx wrangler secret put ADMIN_TOKEN --config packages/bot-worker/wrangler.toml --env production
npx wrangler secret put ADMIN_TOKEN --config packages/bot-worker/wrangler.toml --env preview
npx wrangler secret put TELEGRAM_WEBHOOK_SECRET --config packages/bot-worker/wrangler.toml --env production
npx wrangler secret put TELEGRAM_WEBHOOK_SECRET --config packages/bot-worker/wrangler.toml --env preview
npx wrangler secret put BOT_TOKEN --config packages/bot-worker/wrangler.jsonc --env production
npx wrangler secret put BOT_TOKEN --config packages/bot-worker/wrangler.jsonc --env preview
npx wrangler secret put ADMIN_TOKEN --config packages/bot-worker/wrangler.jsonc --env production
npx wrangler secret put ADMIN_TOKEN --config packages/bot-worker/wrangler.jsonc --env preview
npx wrangler secret put TELEGRAM_WEBHOOK_SECRET --config packages/bot-worker/wrangler.jsonc --env production
npx wrangler secret put TELEGRAM_WEBHOOK_SECRET --config packages/bot-worker/wrangler.jsonc --env preview
```

Use a dedicated test bot token for the preview environment. In GitHub Actions,
Expand All @@ -81,7 +81,7 @@ set `TEST_BOT_TOKEN`; the workflow syncs it into the preview Worker as
`TELEGRAM_WEBHOOK_SECRET` is optional, but recommended for production.

Report sharing uses the `REPORT_DATA_BUCKET` R2 binding declared in
`packages/bot-worker/wrangler.toml`. Deploys use separate preview and
`packages/bot-worker/wrangler.jsonc`. Deploys use separate preview and
production buckets, and the deploy script creates the target bucket when it is
missing during a real deploy. The deploy `CLOUDFLARE_API_TOKEN` must include
R2 Admin Read & Write permission for bucket creation.
Expand Down Expand Up @@ -112,7 +112,7 @@ Deploy production and register the Telegram webhook:
npm run deploy:setup
```

The Worker has explicit Wrangler environments in `packages/bot-worker/wrangler.toml`:
The Worker has explicit Wrangler environments in `packages/bot-worker/wrangler.jsonc`:

- `preview`: deploys `tgbot-preview` on `workers.dev`, binds the custom domain from repository variable `PREVIEW_WORKER_URL`, uses `Libchecker_TG_Bot_Preview`, uses `TEST_BOT_TOKEN` for preview bot testing, points report buttons at `PREVIEW_WEBUI_SITE_URL` or the fixed Cloudflare Pages preview alias, registers the preview Web UI Pages custom domain when configured, and injects the preview Worker origin so Web UI report links can resolve `?r=...`.
- `production`: deploys `tgbot`, binds the custom domain from repository variable `WORKER_URL`, uses `Libchecker_TG_Bot`, injects that URL as `PUBLIC_WEBHOOK_URL`, points report buttons at `WEBUI_SITE_URL`, registers the production Web UI Pages custom domain when configured, and injects the production Worker origin so Web UI report links can resolve `?r=...`.
Expand Down Expand Up @@ -259,7 +259,7 @@ packages/
report-store.js R2 report data storage
observability.js Logs and Analytics Engine events
scripts/ Worker admin and webhook helpers
wrangler.toml Worker deployment config
wrangler.jsonc Worker deployment config
apk-webui/ Web UI Pages workspace package
src/ Browser UI and analyzer worker
functions/ Pages Functions endpoints
Expand Down
Loading
Loading