#!/usr/bin/env bash # Deploy phasefinal.com to Cloudflare Pages (project `phasefinal`, account vh@phasefinal). # stacks/phasefinal-web/deploy-pages.sh # The site is the static tree in conf/site/ (with its _headers and 404.html); there is no build step. # Token: the account token `infra-ops-pages` (Pages Write + zone DNS/redirect/cache), vaulted at # nh3-dev/.config/cloudflare/infra-ops-pages-token. Override with PAGES_TOKEN_KEY. set -euo pipefail here=$(cd "$(dirname "$0")" && pwd) key=${PAGES_TOKEN_KEY:-nh3-dev/.config/cloudflare/infra-ops-pages-token} CLOUDFLARE_API_TOKEN=$(secret get "$key") || { echo "no token at vault key $key (set PAGES_TOKEN_KEY)" >&2; exit 2; } export CLOUDFLARE_API_TOKEN CLOUDFLARE_ACCOUNT_ID=$(curl -s -m 15 -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" https://api.cloudflare.com/client/v4/accounts \ | python3 -c 'import json,sys; r=json.load(sys.stdin)["result"]; print(next(a["id"] for a in r if a["name"]=="vh@phasefinal"))') export CLOUDFLARE_ACCOUNT_ID # run wrangler from a scratch dir so it never drops .wrangler/ state into the repo cd "$(mktemp -d)" npx -y wrangler@4 pages deploy "$here/conf/site" --project-name phasefinal --branch main --commit-dirty=true \ --commit-message "deploy from eshpfi-management $(git -C "$here" rev-parse --short HEAD)"