Something went wrong. Try again.
Monorepo for Aesthetic.Computer aesthetic.computer
Something went wrong. Try again.
core publish-gym.command
1.6 kB · 52 lines
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253#!/bin/zshset -euo pipefailscript_dir=${0:A:h}html_file=${1:-"$PWD/index.html"}if [[ ! -f "$html_file" ]]; then print -u2 "publish-gym: HTML file not found: $html_file" print -u2 "usage: ./publish-gym.command [path/to/index.html]" exit 2fi# Prefer an already-exported token, then a dedicated env file beside this# script or in the current project. Parse only the one expected key instead of# sourcing the file as shell code.token=${GYM_PUBLISH_TOKEN:-}if [[ -z "$token" ]]; then for env_file in \ "${GYM_ENV_FILE:-}" \ "$script_dir/gym.anthonyzollo.env" \ "$PWD/gym.anthonyzollo.env" \ "$PWD/.env" do [[ -n "$env_file" && -f "$env_file" ]] || continue token=$(sed -n 's/^GYM_PUBLISH_TOKEN=//p' "$env_file" | head -1) [[ -n "$token" ]] && break donefiif [[ ! "$token" =~ '^[0-9a-f]{64}$' ]]; then print -u2 "publish-gym: GYM_PUBLISH_TOKEN is missing or invalid." print -u2 "Put gym.anthonyzollo.env beside this script or in the project folder." exit 2fiprint "Publishing ${html_file} → https://gym.anthonyzollo.com/"# Retries cover temporary DNS propagation, resolver, and connection failures.response=$(curl --silent --show-error --fail-with-body \ --retry 5 \ --retry-all-errors \ --retry-delay 2 \ --connect-timeout 15 \ --request PUT \ --header "Authorization: Bearer $token" \ --header "Content-Type: text/html; charset=utf-8" \ --data-binary "@$html_file" \ https://gym.anthonyzollo.com/api/publish-gym)unset tokenprint "$response"print "Published. Open: https://gym.anthonyzollo.com/"