jevhooks.git / tools / deploy-web.sh
1#!/usr/bin/env bash
2# The owner's deploy of the website Worker (`jevhooks`, web/) to hooks.lmjtfy.fun.
3#
4#     tools/deploy-web.sh [wrangler deploy arguments...]      (mise run web:deploy)
5#
6# Runs under `tools/with-secrets.sh`, so fnox supplies CLOUDFLARE_API_TOKEN and
7# CLOUDFLARE_ACCOUNT_ID (declared in fnox.toml) when a provider is set for them; otherwise both
8# must already be in the environment, which is where wrangler reads them. It refuses, saying so,
9# when either is missing. SITE_ORIGIN is the canonical address: every other address the Worker is
10# reached at sends a reader on to it.
11set -euo pipefail
12cd "$(dirname "$0")/.."
13
14if [ -z "${JEVHOOKS_DEPLOY_INNER:-}" ]; then
15  exec env JEVHOOKS_DEPLOY_INNER=1 tools/with-secrets.sh "$0" "$@"
16fi
17
18for name in CLOUDFLARE_API_TOKEN CLOUDFLARE_ACCOUNT_ID; do
19  if [ -z "${!name:-}" ]; then
20    echo "deploy-web: $name is not set. Export it, or set a fnox provider for it (see fnox.toml), and run again." >&2
21    exit 1
22  fi
23done
24
25cd web
26exec wrangler deploy --var "SITE_ORIGIN:${SITE_ORIGIN:-https://hooks.lmjtfy.fun}" "$@"