A Discord bot that handles elo rating, matchmaking, and leaderboards.
For each environment, create a cloudflare worker. Update the worker's name in wrangler.toml
. The following variables should match in the worker's environment variables and in wrangler.toml
-
ENVIRONMENT
. e.g. "production" -
BASE_URL
in the formathttps://<subdomain>.workers.dev
For each environment, create a Discord app. Save the DISCORD_TOKEN
, APPLICATION_ID
, PUBLIC_KEY
, and CLIENT_SECRET
variables
In the dev portal, set the interactions endpoint url, linked roles verification url, and the oauth redirect URI to https://<subdomain>.workers.dev/<endpoint>
according to the endpoints in src/main/router.ts
For each environment, create a Neon database. Save the pooled connection string as POSTGRES_URL
or POSTGRES_URL_TEST
Create a "browser javascript" Sentry project. Save the SENTRY_DSN
variable
For each environment, set these as environment secrets in GitHub Actions
DISCORD_TOKEN
,APPLICATION_ID
,PUBLIC_KEY
,CLIENT_SECRET
, andPOSTGRES_URL
Set the following as repository secrets in GitHub Actions
-
SENTRY_DSN
to the Sentry DSN -
APP_KEY
to a random string. It's used to authenticate requests to the deploy and test endpoints -
CF_API_TOKEN
to your Cloudflare API token
In the workflow file for each environment in .github/workflows
, set the INIT_APP_ENDPOINT
environment variable to https://<subdomain>.workers.dev/init
npm install
npm install -g wrangler
Generate migrations
npx drizzle-kit generate:pg
Set POSTGRES_URL
and optionally POSTGRES_URL_TEST
in .env
Set all of the environment variables in the Cloudflare worker with wrangler secret put <secret>
for each of DISCORD_TOKEN
, APPLICATION_ID
, PUBLIC_KEY
, CLIENT_SECRET
, POSTGRES_URL
, SENTRY_DSN
, and APP_KEY
chmod +x ./deploy.sh
./deploy.sh
Create a .dev.vars file with a testing POSTGRES_URL
, APP_KEY
, and SENTRY_DSN
wrangler dev
curl.exe -X POST <localhost url>/test -H "Authorization:<app key>"