zudo-slack-notify

Type to search...

to open search from anywhere

Configure secrets and deploy

Choose where your Worker lives, generate the relay key, set the three Worker secrets, and deploy.

The relay's runtime configuration lives in three Cloudflare Worker secrets. Nothing secret goes into the repository, and nothing needs to live in any particular directory on your machine. If you deploy through GitHub Actions, the only other secrets are the Cloudflare deploy credentials, stored as GitHub repository secrets.

All commands below run from the repository root unless they say cd app.

1. Choose where your Worker lives

The API Worker's hostname comes from app/wrangler.toml. The file in the repository points at the maintainer's own domain, so change it before your first deploy. Pick one:

  • Your own custom domain. Replace the pattern in the [[routes]] block with a hostname on a zone in your Cloudflare account:

    [[routes]]
    pattern = "notify.example.com"
    custom_domain = true
  • A workers.dev subdomain. Set workers_dev = true near the top of the file, and delete the whole [[routes]] block. The Worker is then served at https://zudo-slack-notify-app.<your-subdomain>.workers.dev.

Keep top-level settings above the tables

In wrangler.toml, a top-level setting such as workers_dev must come before any [table] like [observability] or [[routes]], or TOML treats it as part of that table.

The rest of this guide calls your origin https://notify.example.com. Substitute your own.

2. Generate the relay key

The relay key is the shared bearer secret your scripts present to the Worker: 32 to 256 printable ASCII characters with no spaces. Generate 64 hex characters:

openssl rand -hex 32

Keep your own copy wherever you keep secrets: a password manager, an ignored env file outside the checkout, or similar. You need it again for every sender.

3. Set the Worker secrets

The Worker reads three secrets. Set each one from app/; wrangler secret put prompts for the value, so it never appears on the command line or in your shell history.

cd app
pnpm exec wrangler secret put NOTIFY_API_KEY
pnpm exec wrangler secret put SLACK_BOT_TOKEN
pnpm exec wrangler secret put SLACK_TARGETS
  • NOTIFY_API_KEY: the relay key from step 2.

  • SLACK_BOT_TOKEN: the xoxb-… Bot User OAuth Token from Create the Slack app.

  • SLACK_TARGETS: a JSON object mapping each target alias to a Slack channel ID, on one line:

    { "dev": "C0123456789", "releases": "C0123456789" }

    Aliases are lowercase kebab-case (at most 64 characters); channel IDs start with C, G, or D. The map holds 1 to 100 aliases. It is a secret rather than a plain variable so that your channel IDs stay out of git.

If the Worker does not exist yet, wrangler offers to create it when you set the first secret. You can also deploy first (step 4) and set the secrets afterwards; the order does not matter. Secrets persist across later deploys.

Set all three at once

pnpm ops:push-secrets --env-file <path> reads NOTIFY_API_KEY, SLACK_BOT_TOKEN, and SLACK_TARGETS from a KEY=value file, validates them with the same rules the Worker applies, and uploads them in one go without printing values. Instead of --env-file, you can set ZUDO_SLACK_NOTIFY_WORKER_ENV to the file's path. Add --dry-run to validate only. See Secrets and rotation.

4. Deploy

Deploy the API Worker straight from your machine:

cd app
pnpm exec wrangler deploy

Wrangler asks you to log in to Cloudflare the first time. Redeploy the same way after you pull changes.

Fail closed until wired

Until all three secrets exist and are valid, POST /v1/notify answers 503 server_misconfigured before authentication and before any Slack request. GET /healthz still answers 200, so you can confirm the deploy itself worked.

Next: send the first message.

Revision History

CreatedUpdated