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
6 changes: 5 additions & 1 deletion .github/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

## Production

### Deploys

`production.yml` deploys the `tipbot` Worker through the [Cloudflare Deploy Broker](https://github.com/tempoxyz/cloudflare-deploy-broker). It holds no Cloudflare credential: the broker applies pending D1 migrations, then uploads and promotes the version. `tempoxyz/cloudflare-deploy-policies` authorizes its bindings, so a new binding or Durable Object class needs a policy change first. The Worker keeps its secrets; add or change them in the broker dashboard (https://cf.tehq.net/, Workers tab).

### Cloudflare API token

Create or update the deployment token in the [Cloudflare API Tokens dashboard](https://dash.cloudflare.com/profile/api-tokens).
Previews (`preview_deploy.yml`, `preview_destroy.yml`, `preview_sweep.yml`) still use the `preview` environment's `CLOUDFLARE_API_TOKEN`. Create or update it in the [Cloudflare API Tokens dashboard](https://dash.cloudflare.com/profile/api-tokens).

This API token will affect the below accounts and zones, along with their respective permissions:

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/preview_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ jobs:
PR_NUMBER: ${{ inputs.pr_number }}
TWITTER_BOT_HANDLE: ${{ vars.TWITTER_BOT_HANDLE || env.TWITTER_BOT_HANDLE }}
run: |
# tipbot-preview-name is the placeholder since Wrangler 4.151, which
# rejects __PREVIEW_NAME__. Branches from before keep the old one.
sed -i.bak \
-e "s|\"tipbot-preview-name\"|\"${PREVIEW_NAME}\"|g" \
-e "s|__PREVIEW_NAME__|${PREVIEW_NAME}|g" \
-e "s|__PREVIEW_APEX__|${PREVIEW_APEX}|g" \
-e "s|__PREVIEW_PR_NUMBER__|${PR_NUMBER}|g" \
Expand Down
136 changes: 76 additions & 60 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ on:

permissions: {}

# One run at a time, in push order, never cancelled: the broker finishes work a
# cancelled job started, so overlapping runs could deploy out of order. GitHub
# keeps only the newest pending run, so main's latest commit deploys last.
concurrency:
group: production
cancel-in-progress: false

env:
WRANGLER_SEND_METRICS: false

Expand Down Expand Up @@ -40,78 +47,87 @@ jobs:
id-token: write
uses: ./.github/workflows/check.yml # zizmor: ignore[self-repository] actionlint does not support $/ references yet.

deploy:
name: Deploy
needs: check
# The build reads the production Slack app ID, a GitHub environment variable,
# which only a job in that environment can see. It is public: tip.bot serves
# it in a meta tag.
settings:
name: Settings
needs: authorize
runs-on: ubuntu-latest
environment: production
permissions:
contents: read
id-token: write
outputs:
slack_app_id: ${{ steps.slack_app_id.outputs.value }}
steps:
- name: Secure runner
uses: tempoxyz/gh-actions/actions/secure-runner@35019557465e3c38ee3468be171771fd73577584 # 2026-10-20T06-22-38Z-35019557

- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false

- name: Setup pnpm
uses: ./.github/actions/setup-pnpm # zizmor: ignore[self-repository] actionlint does not support $/ references yet.

- name: Run migrations
run: pnpm exec wrangler d1 migrations apply tipbot --env production --remote
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

- name: Build
run: pnpm build
- name: Read the Slack app ID
id: slack_app_id
env:
CLOUDFLARE_ENV: production
SLACK_APP_ID: ${{ vars.SLACK_APP_ID }}
run: |
if [[ ! "$SLACK_APP_ID" =~ ^A[0-9A-Z]{6,32}$ ]]; then
echo "::error::The production environment's SLACK_APP_ID is not a Slack app ID."
exit 1
fi
echo "value=${SLACK_APP_ID}" >> "$GITHUB_OUTPUT"

# Builds and attests the Worker, its chunks, static assets, configuration and
# D1 migrations without any Cloudflare credential. The deploy job hands the
# artifact to the Cloudflare Deploy Broker, whose tipbot authorization admits
# only this workflow on main, in the production environment.
build:
name: Build
needs: [check, settings]
permissions:
actions: write
artifact-metadata: write
attestations: write
contents: read
id-token: write
uses: tempoxyz/gh-actions/.github/workflows/cloudflare-deploy-broker-build.yml@1a535d662a51f211d750307541069cb849535414 # 2026-11-19T07-33-38Z-1a535d66
with:
build-command: SLACK_APP_ID=${{ needs.settings.outputs.slack_app_id }} pnpm build:broker
wrangler-config: dist/server/wrangler.json
d1-migrations-directory: db/migrations
artifact-name: tipbot

- name: Deploy to Production
uses: tempoxyz/gh-actions/vendor/cloudflare/wrangler-action@35019557465e3c38ee3468be171771fd73577584 # 2026-10-20T06-22-38Z-35019557
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
timeout-minutes: 20
environment: production
permissions:
contents: read
id-token: write
steps:
- name: Secure runner
uses: tempoxyz/gh-actions/actions/secure-runner@35019557465e3c38ee3468be171771fd73577584 # 2026-10-20T06-22-38Z-35019557

# The broker applies pending D1 migrations to DB, then uploads and
# promotes the version, and stops before promotion if a migration fails.
# The Worker keeps its secrets; change them in the broker dashboard
# (https://cf.tehq.net/, Workers tab).
- name: Migrate D1 and deploy through the broker
uses: tempoxyz/gh-actions/actions/cloudflare-deploy-broker@1a535d662a51f211d750307541069cb849535414 # 2026-11-19T07-33-38Z-1a535d66
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: deploy --env production
environment: production
secrets: |
FEE_PAYER_PRIVATE_KEY_MAINNET
FEE_PAYER_PRIVATE_KEY_TESTNET
RPC_CREDENTIALS
SECRET_KEY
SLACK_CLIENT_ID
SLACK_CLIENT_SECRET
SLACK_SIGNING_SECRET
TEMPO_API_KEY
TWITTER_ACCESS_TOKEN
TWITTER_ACCESS_TOKEN_SECRET
TWITTER_BEARER_TOKEN
TWITTER_CONSUMER_KEY
TWITTER_CONSUMER_SECRET
TWITTER_OAUTH_CLIENT_ID
TWITTER_OAUTH_CLIENT_SECRET
env:
FEE_PAYER_PRIVATE_KEY_MAINNET: ${{ secrets.FEE_PAYER_PRIVATE_KEY_MAINNET }}
FEE_PAYER_PRIVATE_KEY_TESTNET: ${{ secrets.FEE_PAYER_PRIVATE_KEY_TESTNET }}
RPC_CREDENTIALS: ${{ secrets.RPC_CREDENTIALS }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
SLACK_APP_ID: ${{ vars.SLACK_APP_ID }}
SLACK_CLIENT_ID: ${{ secrets.SLACK_CLIENT_ID }}
SLACK_CLIENT_SECRET: ${{ secrets.SLACK_CLIENT_SECRET }}
SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }}
TEMPO_API_KEY: ${{ secrets.TEMPO_API_KEY }}
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
TWITTER_BEARER_TOKEN: ${{ secrets.TWITTER_BEARER_TOKEN }}
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_OAUTH_CLIENT_ID: ${{ secrets.TWITTER_OAUTH_CLIENT_ID }}
TWITTER_OAUTH_CLIENT_SECRET: ${{ secrets.TWITTER_OAUTH_CLIENT_SECRET }}
deployment-id: tipbot
artifact-id: ${{ needs.build.outputs.artifact-id }}
archive-digest: ${{ needs.build.outputs.archive-digest }}
module-digest: ${{ needs.build.outputs.module-digest }}

# /api/health queries D1.
- name: Check https://tip.bot
run: |
for _ in $(seq 1 10); do
if curl -fsS --max-time 10 https://tip.bot/api/health; then exit 0; fi
Comment on lines +101 to +126

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 nit (optional): Two new time durations have no human-readable comment, which AGENTS.md requires. They are timeout-minutes: 20 at production.yml:101 and curl --max-time 10 at production.yml:126. The neighbouring sleep 6 # 6 seconds follows the rule. Fix: add trailing comments such as # 20 minutes and # 10 seconds.

Why this was flagged

AGENTS.md:52 says every added time duration or amount needs a comment next to it giving the human-readable time. The diff adds timeout-minutes: 20 to the deploy job at .github/workflows/production.yml:101 and curl -fsS --max-time 10 in the health-check loop at line 126, and neither has a comment. The sleep 6 # 6 seconds two lines below shows the convention the author was following. This is a convention slip only and changes no behaviour. Nothing in CI enforces the rule, so nothing catches it.

Verification: Severity: nit. This is a convention slip that breaks nothing at runtime. AGENTS.md:52 says: "whenever you add a time duration/amount, make sure it has comment next to it with the human-readable time". The diff adds timeout-minutes: 20 at .github/workflows/production.yml:101 and curl -fsS --max-time 10 at line 126, and neither has a comment. Behavior is unaffected.

sleep 6 # 6 seconds
done
echo "::error::https://tip.bot/api/health did not return 200."
exit 1

update_slack_app:
name: Update Slack App
Expand Down
5 changes: 5 additions & 0 deletions db/migrations/0020_telegram_provider.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Placeholder with no effect. Production applied an earlier 0020_telegram_provider.sql
-- (327ef065, Production run 26782816327) before 954bf9bd reverted it, so the production
-- d1_migrations table still records this name. The Cloudflare Deploy Broker applies D1
-- migrations only when every recorded name is one of the repository's, so the name stays.
UPDATE "workspace" SET "updated_at" = "updated_at" WHERE 0;
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"scripts": {
"build": "vp build",
"build:broker": "node --experimental-strip-types scripts/broker-build.ts",
"check": "vp check",
"check:types": "tsgo -b",
"db:codegen": "node --experimental-strip-types db/codegen.ts",
Expand Down Expand Up @@ -37,7 +38,7 @@
"@tanstack/router-plugin": "1.168.46",
"accounts": "^0.15.2",
"chat": "4.27.0",
"hono": "4.13.13",
"hono": "4.13.19",
"kysely": "0.28.17",
"nanoid": "^5.1.16",
"ox": "0.14.20",
Expand Down Expand Up @@ -78,7 +79,7 @@
"vite": "catalog:",
"vite-plus": "catalog:",
"vitest": "catalog:",
"wrangler": "4.91.0"
"wrangler": "4.151.0"
},
"devEngines": {
"runtime": {
Expand Down
Loading
Loading