#!/usr/bin/env bash set -euo pipefail bucket="${1:-baron-qa-pages}" config="${2:-wrangler.toml}" prefix="${3:-}" if [ "$bucket" = "baron-qa-write" ]; then if [ "$config" != "wrangler.production.toml" ] || [[ ! "$prefix" =~ ^releases/[0-9a-f]{40}$ ]]; then echo "Production uploads require the production config and a full commit release prefix" >&2 exit 1 fi fi upload() { local file="$1" local key="${prefix:+$prefix/}$2" local content_type="$3" npx --no-install wrangler r2 object put "$bucket/$key" --config "$config" --file "$file" --content-type "$content_type" --remote } upload egbim/index.html egbim/index.html text/html upload egbim/write.html egbim/write.html text/html upload egbim/detail.html egbim/detail.html text/html upload egbim/app.js egbim/app.js application/javascript upload egbim/config.js egbim/config.js application/javascript while IFS= read -r file; do key="${file#./}" case "$file" in *.css) content_type="text/css" ;; *.js) content_type="application/javascript" ;; *.woff2) content_type="font/woff2" ;; *.svg) content_type="image/svg+xml" ;; *.png) content_type="image/png" ;; *.jpg|*.jpeg) content_type="image/jpeg" ;; *) content_type="application/octet-stream" ;; esac upload "$file" "$key" "$content_type" done < <(find ./assets -type f -not -name '*.map' -print | sort) echo "Uploaded static files to R2 bucket: $bucket"