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