#!/usr/bin/env bash # Push the current commit to the HF Space remote, with server/space/README.md # overlaid at repo root (HF reads the Space's metadata frontmatter from the # root README; the GitHub root README stays untouched). # # Prereq once: # git remote add space https://huggingface.co/spaces/lanczos/graphtestbed # # Auth: export HF_TOKEN before running and the script will inject it into # the push URL; otherwise git will prompt for username/password # (user = lanczos, password = the token). set -euo pipefail BRANCH=$(git rev-parse --abbrev-ref HEAD) TEMP="space-deploy-$(date +%s)" PUSH_TARGET="space" if [[ -n "${HF_TOKEN:-}" ]]; then PUSH_TARGET="https://lanczos:${HF_TOKEN}@huggingface.co/spaces/lanczos/graphtestbed" fi trap 'git checkout "$BRANCH" >/dev/null 2>&1 || true; \ git branch -D "$TEMP" >/dev/null 2>&1 || true' EXIT git checkout -b "$TEMP" # HF Docker SDK looks for Dockerfile at the repo root; our canonical copy # lives in server/space/. Overlay both for the deploy. cp server/space/README.md README.md cp server/space/Dockerfile Dockerfile git add README.md Dockerfile git commit --no-verify -m "deploy: overlay server/space/{README,Dockerfile} at root" git push -f "$PUSH_TARGET" "$TEMP:main" echo echo "pushed to space/main" echo "URL: https://lanczos-graphtestbed.hf.space/"